Wayne Conrad's Blog

home

A Virtualbox Networking Recipe

22 Mar 2016

This is a recipe for setting up a virtual network when using Oracle’s VirtualBox software.

The requirements

Conditions

I tested this recipe with:

The recipe

In this recipe, each VM is dual-homed.The first network interfaces gives the VM access to the internet through the NatNetwork, and also gives the host access to the VMs. The second network interface connects the host and VMs together through a “host-only network.”

Configuring the Host-only network

Configuring each VM’s VirtualBox Network

Configuring each VM OS’s network.

We now configure each VM’s OS to be dual-homed, with one DHCP interface for internet, and one static interface for communicating with other VMs and the host.

Edit /etc/apt/interfaces. You should see something like this:

...
allow-hotplug eth0
iface eht0 inet dhcp

This is the configuration for the NAT interface, the one that connects the VM to the internet. Add the configuration for the “host-only network” interface, the one that connects the VM to other VMs and to the host:

auto eth1
iface eth1 inet static
    address 192.168.51.2      # Unique for each VM.  Do not use .1.
    netmask 255.255.255.0

Now bring up the interface using ifup eth1

Do this for each VM.

Testing

From each VM, you should be able to get to the internet:

ping google.com

You should be able to get to another vm:

ping 192.168.51.2

From the host, you should be able to get to each vm:

ping 192.168.51.2
ping 192.168.51.3
comments powered by Disqus