Just a quick note: I use VirtualBox daily at work. It provides excellent emulation for my original XP install (the one that came pre-installed on my Dell box!) while my main OS is Ubuntu. Setting up networking is not as straightforward as with VMWare, so here is what I had to do:
First, edit /etc/udev/rules.d/20-names.rules and make sure this line exists:
KERNEL="tun", NAME="net/%k" |
Then create this script – you will run it whenever you wish to reconfigure your network:
#!/bin/bash echo "Erasing old configuration" sudo route del default sudo ifconfig tap0 down sudo ifconfig eth0 down sudo ifconfig br0 down sudo brctl delbr br0 sleep 1 echo "Creating virtual interface" sudo chown chris /dev/sdc1 sudo tunctl -t tap0 -u chris sleep 1 echo "Creating bridge interface" sudo brctl addbr br0 sleep 1 echo "Making physical interface promiscuous" sudo ifconfig eth0 0.0.0.0 promisc sleep 1 echo "Binding bridge to physical interface" sudo brctl addif br0 eth0 sleep 1 #sudo ifconfig br0 10.255.203.34 netmask 255.255.255.0 echo "Configuring IP address" sudo ifconfig br0 198.206.186.210 netmask 255.255.255.0 # sudo dhclient br0 # The new way! sleep 1 echo "Binding bridge to virtual interface" sudo brctl addif br0 tap0 sleep 1 echo "Enabling virtual interface" sudo ifconfig tap0 up sleep 1 #sudo route add default gw 10.255.203.254 echo "Adding default route" sudo route add default gw 198.206.186.254 echo "All done!" |
What’s that, then?
We start by getting rid of any existing configuration; then I change my virtual interface device’s owner to my own user, since I am logged in as a non-root user. Obviously you need to replace ‘chris’ with your own user name. From now on, tap0 will be the virtual interface seen by VirtualBox.
I make sure that my real interface is in promiscuous mode, which then allows me to bind it with a bridge interface.
All that is left to do it configure my bridge interface so that it can take over communicating with the rest of the world!







Sorry if this is a dumb question, but does anything special need to be done with the /etc/network/interfaces file? Should it be blank? Should eth0 be set to manual and have no ip settings in the file? Thanks for any direction about this.!!
Correct; the whole setup is done using this script, thus leaving interfaces blank.
Note that you can put a default configuration in interfaces and only run this script when/if you need bridging since the script starts by cleaning up any configuration.
If you are interested in bridging, this post is still valid.
If, however, you are simply wondering how to easily setup networking for VirtualBox, note that it seems that the latest release of VB will take care of all this for you. What it lacks in flexibility it certainly makes up for in ease of use.
VERY NICE setup thanks. i used it to configure my slackware-virtualbox on win xp 64. these were my steps :
-added a host-only eth adapter for virtualbox machine
-installed wingate for NAT (easy to configure but hard to find a valid license or crack)
- bridged “local area connection” with the host-only eth adapter . added an ip 192.168.0.2 to this bridge .
here is my config added to rc.local …
/bin/mknod /dev/tun c 10 20 (download tunctl-1.X.tar.gz .)
/usr/sbin/tunctl -t tap0 -u user
/sbin/brctl addbr br0
/sbin/ifconfig eth0 0.0.0.0 promisc
/sbin/brctl addif br0 eth0
/sbin/ifconfig br0 192.168.0.9 netmask 255.255.255.0
/sbin/brctl addif br0 tap0
/sbin/ifconfig tap0 up
/sbin/route add default gw 192.168.0.2
-add 2 ns to resolv.conf … ping something.com and it works