Network interfaces for Ubuntu VirtualBox guest on Windows host

To work effectively and relatively securely on a VirtualBox guest system, the guest needs two network adapters - a NAT and a host-only adapter. The NAT interface allows talking out to the internet, and the host-only adapter allows ssh and http in from the host.

However, it seems that Ubunt/Debian only recognizes one network interface on system installation.

So to get two interfaces on the guest, I found the following to work :

First, create a host-only network for all VirtualBox instances. I think of this as creating a VirtualBox router. This is done thru File -> Preferences -> Networks. It should have values something like this :

IPv4 Address : 192.168.56.1
IPv4 Network Mask : 255.255.255.0

Then, create a new virtual machine with two network adapters. The first is NAT. The second is host-only, and use the 'Name' of the network you just created (ex. 'VirtualBox Host-Only Ethernet Adapter #1').

Boot your VM with the Ubuntu CD (.iso). Install Ubuntu. You may be asked a question or two about networking. As I recall you can take the defaults, skip, or make a 'best guess'.

After installing Ubuntu (and rebooting), ifconfig should yield the following :


eth0 Link encap:Ethernet HWaddr 08:00:27:36:dc:0e
inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0
...

So aside from local, you'll only have one NAT Ethernet adapter. To add the second, host-only, adapter, add the following to /etc/network/interfaces :


# For host-only interface
auto eth1
iface eth1 inet static
address 192.168.56.151
netmask 255.255.255.0
network 192.168.56.0
broadcast 192.168.56.255

Of course you'll have to vary the details to match your desired static IP and other network ('virtual router') details.

Now restart network services (or reboot) and you should have two network adapters.

The following are also useful for this :

http://christophermaier.name/blog/2010/09/01/host-only-networking-with-v...

https://muffinresearch.co.uk/howto-ssh-into-virtualbox-3-linux-guests/

http://coding4streetcred.com/blog/post/VirtualBox-Configuring-Static-IPs...

Categories: