Apr 1 2009

Bridge Virtual Windows XP Installation to Linux so VirtualBox Can Access Your Network Shares. Only the useful instructions.

This quick tutorial or example displays how to quickly bridge your windows xp install in virtual box running on Linux to your local area network so you can stream video or just acces your network shares.

I set up a windows xp virtual box on my ubuntu 8.04 desktop so I could stream H.264 high def content to my xbox 360 using tversity.
Because Virtual Box is by default set up on a different subnet this would not work as easily as I would like. Here is only the useful information on how to set up a network bridge between Linux and Virtualbox.

Install virtualbox on ubuntu and set up windows xp. For anyone trying to follow these instructions then this should be simple. Google it and use apt-get.

These packages are required for the bridge.


sudo apt-get install uml-utilities bridge-utils

Now create TAP interface. The tap interface is a software loopback mechanism.


sudo tunctl -t tap1 -u username

where username is obviously your username.

Create a bridge named br0


sudo brctl addbr br0

Put your physical network interface into promiscuous mode


sudo ifconfig eth0 0.0.0.0 promisc


Link your physical interface to the bridge br0 that we created
<code>
sudo brctl addif br0 eth0

Give the bridge br0 a static IP address or use DHCP
Static:


sudo ifconfig br0 192.168.1.12

DHCP:

sudo dhclient br0

Link the tap interface to your bridge br0


sudo brctl addif br0 tap1

You will now need to activate the tap interface using the ifconfig command


sudo ifconfig tap1 up

Alter the permissions of the tunnel device


sudo chmod 0666 /dev/net/tun

Now, assuming that you got virtual box installed and working, (If you can’t then you need to play with linux more, It’s really not that hard)
Start VirtualBox but don’t start your windows installation. Click on Settings, select Network and then set ‘Attached to’ to “Host Interface” and add tap1 to Interface Name.

Boot up your virtual windows xp installation and change the IP address of the local area connection in network connections to an ip on the same subnet.
You will have to set the proper gateway and possibly the dns servers. Although typically these can just be set to the same as the gateway.

when you reboot Linux and want to use the windows install on the same network then you will have to repeat most of that stuff. I use a shell script that runs it on boot.
Here is an example of one that you could use. Fill in your own info of course.


#must run as root
tunctl -t tap1 -u codytaylor
brctl addbr br0
ifconfig eth0 0.0.0.0 promisc
brctl addif br0 eth0
sleep 10
dhclient br0
brctl addif br0 tap1
ifconfig tap1 up
chmod 0666 /dev/net/tun

-Cody Taylor

Share