VirtualBox networking…finally!

I honestly never thought I’d see the day, but I’ve finally found a way that seems to work (touch wood!) to allow me to run virtual machines in VirtualBox on my Ubuntu host, and allow two-way access to the network with a bridged interface!

Translation: my virtual machines have an IP address on my internal network and act as if they were machines on my network.

To do this, I’ve hunted high and low and the best summary page I found was this one.  Basically:

  1. Install brctl and uml-utilities
  2. Create the following script in /etc/rc.local, replacing everything in [ ]:
    tunctl -t tap0 -u [username]
      chmod 0666 /dev/net/tun
      /usr/sbin/brctl addbr br0
      /sbin/ifconfig eth0 0.0.0.0 promisc
      /usr/sbin/brctl addif br0 eth0
      /sbin/dhclient br0
      /usr/sbin/brctl addif br0 tap0
      ifconfig tap0 [IP for virtual machine] tunctl -t tap0 -u [username]
      chmod 0666 /dev/net/tun
      /usr/sbin/brctl addbr br0
      /sbin/ifconfig eth0 0.0.0.0 promisc
      /usr/sbin/brctl addif br0 eth0
      /sbin/dhclient br0
      /usr/sbin/brctl addif br0 tap0
      ifconfig tap0 [IP for virtual machine] up
      bash -c 'echo 1 > /proc/sys/net/ipv4/conf/tap0/proxy_arp'
      route add -host [VirtualBox server/PC IP address] dev tap0
      arp -Ds [VirtualBox server/PC IP address] eth0 pub
    exit 0
  3. In VirtualBox, set the virtual machine to have “Attached to” set to “Host interface” and the “Interface Name” to “tap0”.

It just works!  🙂  You should be able to add other taps for other machines…I think.

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s