2008
12.14

Recently i started a little PHP Project, where i wanted to manage Microsofts DNS server via a nice little web interface, of course i would have to use COM Object for this.

So, first off, i needed a Windows Server machine… a friend told me that VMWare Server was free to use, so i grabbed it. That turned out to be a dead end, after installation it just hung my PC (Running server 2003 or 2008) so i removed that, and installed Virtual Box. It’s great, simple to use (more like VMWare Workstation, whcih didn’t work either.) and fast, which is just what i was after.

# wget http://download.virtualbox.org/virtualbox/2.0.6/virtualbox-2.0_2.0.6-39765_Ubuntu_intrepid_amd64.deb
# sudo ipkg --install virtualbox-2*.deb

And that was it, VirtualBox installed and ready to run. All seemed too easy. Why wasn’t VMWare this easy?

VirtualBox Main Window

VirtualBox Main Window

As you can see, i’ve taken this screenshot after i’ve got an installed version of 2008 running. All you have to do is click New, follow the few simple steps, mount your CD/DVD and click run. That really is it. Follow the install instructions, and within ~30mins you should have a full Windows 2008 VM Running.

Now i came across a slight issue. The network configuration defaults to NAT Type, which is fine for most. As it uses your PC’s connection for it’s network, so you have an internal IP address. You will be able to connect to the internet (as it’s routed through your PC – The host). But, the internet will not be able to connect to you. I needed to be able to view my IIS Server remotely, from another machine across the globe.

So to do this, the network has to be setup as ‘Host Interface’, which means you can use an interface from the host machine. So, we also need to create a new host on the virtual machine, which will bridge between eth0 (eth0 in my case, could be ethX for you).

This is how your Network pane should look.

VirtualBox Settings

tap0 is the device name we need to create, which can be done by create a simple bash script that creates the new device, sets up the bridge between your ethX and the tap0 and then gets an IP Address for the tap0 device.

#!/bin/bash
#$1 = Username
#$2 = Local Device
#$3 = EthX IP Address
#$4 = Tap0 IP Address
 
sudo tunctl -t tap0 -u $1
sudo chmod 666 /dev/net/tun
sudo /usr/sbin/brctl addbr br0
sudo /sbin/ifconfig eth0 0.0.0.0 promisc
sudo /usr/sbin/brctl addif br0 $2
sudo /sbin/dhclient br0
sudo /usr/sbin/brctl addif br0 tap0
sudo ifconfig tap0 $4 up
sudo bash -c 'echo 1 > /proc/sys/net/ipv4/conf/tap0/proxy_arp'
sudo route add -host $3 dev tap0
sudo arp -Ds $3 $2 pub

Save this as createbridge.sh.

This script requires 4 parameters, your local username (in my case it was dean ;) ), the local device you want to bridge (eth0 for me), the IP address of your eth0 device (192.168.1.100 for me) and the IP Address you want the tap0 device to get (i chose 192.168.1.200), i call it like this when i log onto my machine.

# sh createbridge.sh dean eth0 192.168.1.100 192.168.1.200

Wait for it to finish, then you should have a new br0 device which is the bridge which will have the IP Address of your ethX device. You should also have a new device called tap0 which will have the IP Address you specified, mine being 192.168.1.200.

And that is it, i fired up my VM, straight into Windows, instantly viewable from the network and the internet. Perfect!

Hope this helps people that had the same problem.

1 comment so far

Add Your Comment
  1. great article. will try vitualbox when i get some spare time =).
    cheers,
    Z

Spiked Software Coding Articles is Digg proof thanks to caching by WP Super Cache