Sunday, February 22, 2009

Setting up a network bridge for Virtualbox under Kubuntu 9.04 (JJ)

Update Mon 13 July 2009: You no longer need to jump through hoops to build a network bridge. This can now be build by the Virtualbox GUI. I will keep this post for reference.

If you want to run something like Cisco VPN under virtualbox you need to setup a network bridge. If you want to run a server inside a virtual machine (for example ClarkConnect) you need to setup a network bridge.


Step 1:
Download and install virtualbox from http://www.virtualbox.org/wiki/Downloads

Step 2: Install bridge-utils to be able to create network bridges:

$ sudo apt-get install bridge-utils

Step 3: edit /etc/network/interfaces. I normally use MC (Midnight Commander) to edit the configuration files. Use "sudo mc" to start Midnight Commander with superuser access.

The interfaces file should look like this after editing it:
auto eth0
iface eth0 inet manual

auto br0
iface br0 inet dhcp
bridge_ports eth0 vbox0

# The loopback network interface
auto lo
iface lo inet loopback
Step 4: Restart networking with:
sudo /etc/init.d/networking restart
Step 5: edit /etc/vbox/interfaces
Change riaan to your userid. If the 'interaces' file does not exist then create the file. The file should look like this:
vbox0 riaan br0
Step6: Restart Virtualbox module
sudo /etc/init.d/vboxdrv restart
Step 7: Set TUN permissions
$ sudo chmod g+rw /dev/net/tun
$ sudo chown root:vboxusers /dev/net/tun

Edit or create the file /etc/udev/rules.d/20-names.rules
The contents of the file should look like this:
KERNEL=="tun", NAME="net/%k", GROUP="vboxusers", MODE="0660"

Step 8: Start Virtualbox GUI.
Start the VirtualBox management interface on the host machine, configure the network of your virtual machine by selecting "host networking" and then select br0 for the virtual adapter.
blog comments powered by Disqus