sábado, 20 de agosto de 2011

How to configure Host-only networking in VirtualBox 4. Ubuntu host and Windows guest.

Hi all,

after studying several manuals and howtos about VirtualBox and networking between the host machine and the guest machine I guess that I have find the short and easiest way to configure it using Host-only networking, for me the most complete option.

We will split the explanation in three parts: virtualbox, host and guest configuration.

If we follow all the steps we will be able to connect with the devices of the host's LAN and Internet.

By the way, you can find more information about VirtualBox networking information in http://www.virtualbox.org/manual/ch06.html.


First part. VirtualBox configuration.

It is the easiest step. We assume that when we have installed the VirtualBox packet the network virtual interface has been installed too. It is what usually happens. The name of this interface is vboxnet0.

To configure the interface in the program we must select the virtual machine target and press Settings >> Network. Then select Host-only adapter and select the name vboxnet0 for the adapter. It is not necessary to configure the advanced parameters.



Second part. Host configuration (in our case Ubuntu)


To configure the host basically we should activate the virtual interface assigning an IP and, configure the Iptables to perform NAT translation and enable the port forwarding to be able to communicate to the external machines (LAN or Internet). As we need to have it configured each time we switch on the host, we will put the required script in /etc/rc.local.

#*****************************************************************
# Configure virtual interface vboxnet0 for VirtualBox
echo "Setting up vboxnet0 interface..."
ifconfig vboxnet0 192.168.56.1 up

# *****************************************************************
# Enable NAT and fordwarding
echo "Enabling NAT and fordwarding..."
iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
echo 1 > /proc/sys/net/ipv4/ip_forward

exit 0


Last part. Guest configuration (in our case Windows7)

Finally we power on the virtual machine and as it is Windows7 we configure the Local Area Connection as is shown in the following pic.




No hay comentarios:

Publicar un comentario