Tackling VirtualBox access to local network (Windows XP as guest)

November 4, 2008 at 12:57 am (linux) (, , )

A few days ago, I installed VirtualBox and installed Windows XP SP2 as the guest OS. This is not so much a review but a tale of my experiment trying to set up Windows and the issue I faced while configuring the network and the printer on a local network.

Before getting started, it is important to understand that there’s two different flavor of VirtualBox mainly available out there: OSE (Open Source Edition) and the Sun’s version. While both are available for free (as free beer) only the OSE is Open Source. Sun’s license let’s people download it if it’s not for commercial uses. Because the OSE version lacks some features like the USB support, I decided to install the Sun’s version and while the two versions are very similar, you might encounter different issues if you’re following this guide on an OSE version.

Now that the warning is out there, let’s proceed.

First of all, the installation is very easy. I think there’s enough instruction out there that it would be pointless to do a walkthrough.If you need such a walkthrough, taufanlubis has made a nice one with Ubuntu as the Host OS.

What I wanted to do was to install Windows XP and access to my local network where there’s a printer accessible through Samba and where I had a few folders also accessible through the same protocol. If you need information on how to set up a printer on Samba, here’s a LUG that gathers information on how to do so.

Okay. so now, Windows XP is installed, you might or might not have access to the internet when you’re on WinXP but we suppose that your linux installation is connected to the server.

We will use the Host Interface on VirtualBox to get in the local network subnet. To achieve that, we start with creating a tunnel, then a bridge to connect the tunnel with the actual interface and then we’ll connect all those guys together so we get everything working. Once everything is working we will simply set up Virtual Box to get his internet information from the tunnel.

First we create the tunnel:

sudo tunctl -t tap0 -u user

sudo chmod 666 /dev/net/tun

where ‘user’ is the user WindowsXP will run on.

2. We create a bridge

sudo brctl addbr br0

3. We suppose that the interface that used to be connected on the internet was eth0

sudo ifconfig eth0 0.0.0.0 promisc

sudo brctl addif br0 eth0

4. Now, we want to connect the BRIDGE to the internet, not eth0 (the interface we used in the past). We suppose that you’re interface was being set up through dhcp.

sudo dhclient br0

5. We connect the tunnel to the bridge and set it up with an ip that belongs to the subnet (here we use the 192.168.0.0 subnet)

sudo brctl addif br0 tap0

sudo ifconfig tap0 192.168.0.45 up

6. Time to create the proxy and add the route to make sure all the connection are bonded together

sudo bash -c ‘echo 1 > /proc/sys/net/ipv4/conf/tap0/proxy_arp’

sudo route add -host 192.168.0.32

sudo arp -Ds 192.168.0.32

the ip used in the last 2 lines are the ip you are connected with br0. Once this is done, you go back to you VirtualBox and select you’re WindowsXP installation. Go into the Settings->Network and in the Attached To selectbox, select “Host Interface” and in the Host Interface Settings lower, enter tap0 in Interface Name.

You should now be able to access you’re printer and you’re shared folders. If you can’t install the driver like what happened to me (Samsung ML-2010) because the installation requested to have a USB port available even though you’re printer was not connected to the computer (Local Network…) you need to enable the USB support in your Windows XP Settings. You might need to also install the Guest Additions, but I think you can achieve all that without the add-on.

Hopefully, this tutorial will help some like it helped me. Most of the stuff written here comes from a forum post made by ipguru99 and it’s available here.

2 Comments

  1. makj said,

    in the last 2 commands you forget to specify the device
    anyways, i’m trying to do this in a gentoo host and it doesn’t work!! the main difference i see is that i don’t have dhcp so instead of:

    sudo dhclient br0

    i’m doing this:

    sudo ifconfig br0 192.168.0.32 up

    (i’m just using here the same value from your example, mine is different)
    is that right ???

    after setting that i can ping the tunneled IP (0.45) from another host, but from inside the virtualbox (a windows 2003 server) i just dont have connection, when i make a ping from there i get a “request timed out” message

    any help, please

  2. pothibo said,

    Well have you changed your virtualBox config to have it connected to your tunnel?

    if so.. you might want to have a look if your tunnel is actually connected to your bridge interface… Here’s how your network should behave

    BR = ETH0 + TUNNEL
    BR = Connected to internet.

    By the way.. your win2003 server is going to have 192.168.0.45 as internal IP.. let me rephrase this so it’s clear: Win2003 Server has your tunnel IP.

    if you can ping the tunnel from anywhere in your subnet but can’t ping anything from 0.45(2003 server) than I suggest you check Vbox’s setting..

Post a Comment