..bits & bytes teleported

Friday Sep 12, 2008

Primary Link: http://www.virtualbox.org


Accessing the host operating system from a guest is as simple at setting up a network adapter attached to NAT and you will be able to access the Internet, ssh to the host and other things.


So how does this work?


The guest gets a IP address via DHCP which is made possible by the internal DHCP server of VirtualBox. The host also gets a IP address which is only accessible by the guest. We can think of it to be a internal IP address. Hence, we can “talk” to the host OS.

However, we cannot communicate in the same way with the guest OS from the host OS. This is expected as this is the very concept of NAT




Solution: Host Interface Networking


From the VirtualBox user manual:


With Host Interface Networking, VirtualBox creates a new networking interface in software on the host computer. This new software interface will then exist in parallel to your regular interfaces (e.g., on a Linux host vbox0 will exist alongside eth0). When a guest is using such a new software interface, it looks to the host system as though the guest were physically connected to the interface using a network cable: the host can send data to the guest through that interface and receive data from it. This means that you can set up routing or bridging between the guest and the rest of your network.


Set up a Network bridge to enable Host Interface Networking


The VirtualBox user manual has detailed instructions for setting up host interface networking on Windows, Linux and Solaris.


Here I will reproduce the steps for Ubuntu Linux 8.04.1



  • Install the bridge-utils package: sudo apt-get install bridge-utils

  • Edit your /etc/network/interfaces to add the following lines:

  • auto br0 <br />iface br0 inet static <br />address 10.10.3.4 <br /> bridge_ports eth0 <br />


  • Restart the networkin services: sudo /etc/init.d/networking restart

  • Create a software host interface: sudo VBoxAddIF vbox0 amit br0 (where 'amit' should be the user who will be running VirtualBox)

  • Modify the network settings of your virtual machine to add the interface 'vbox0' : VBoxManage modifyvm JeOS -hostifdev1 vbox0 (where 'JeOS' is your VM name)

  • Boot up the VM and assign a static IP adress to the interface



Now you can access the Guest from the Host and vice-versa.


For eg. You can have a webserver running on your Guest OS and you can acces it from your Host.

Comments:

Why can't it Just Work, like in VMWare? Why do I have to tinker with br0 and break my network more often than not?

Posted by Mikael Gueck on September 12, 2008 at 08:38 PM IST #

2 questions:
1. what would be the NIC in the guest Solaris?
2. what if u want to assign an IP to this NIC using DHCP?
thanks

Posted by ahmad on September 15, 2008 at 06:48 AM IST #

I seem to be having trouble with my interfaces file, I added that bit onto the end like this:
"
auto lo
iface lo inet loopback
auto br0
iface br0inet static
address 10.10.3.4
bridge_ports eth0
"

And it gives me this error:
"
~$ sudo /etc/init.d/networking restart
* Reconfiguring network interfaces...
/etc/network/interfaces:4: too few parameters for iface line
ifdown: couldn't read interfaces file "/etc/network/interfaces"
/etc/network/interfaces:4: too few parameters for iface line
ifup: couldn't read interfaces file "/etc/network/interfaces"
"

Where is this going wrong?

Posted by Charlie Foxtrot on September 17, 2008 at 07:27 AM IST #

@Charlie Foxtrot: there is a typo in configuration. Replace _ with - :
It should be
bridge-ports eth0

Posted by abdi on September 19, 2008 at 05:27 PM IST #

The correct file should look something like:

auto br0
iface br0 inet static
address 192.168.66.200
network 192.168.66.0
netmask 255.255.255.0
broadcast 192.168.66.255
bridge-ports eth0

Posted by abdi on September 19, 2008 at 05:29 PM IST #

Post a Comment:
Comments are closed for this entry.