By scuzzman at 2006-02-21 15:32
Allow me to start by saying this is a very simple process if you have an iptables script configured, so fear not. Also, although this may be Slackware-specific in parts, it's because of that reason that this information can be (relatively) easily ported to other distributions.
My host (real) setup:
Slackware Linux with kernel 2.6.9
Windows 2000 Pro
If you've not gotten it installed, you'll need qemu installed on your distribution of choice.
You'll need to create an image on your hard-drive for the virtual machine to use as a hard-drive. To do this, I used qemu-img. It was actually quite simple:
Breaking this down:
qemu-img create win2k.img 10G
qemu-img creates the images you'll be using
win2k.img is the name of the file that the virtual machine will be using as a hard-drive
10G is the size of the file - I gave it 10 gigs. The abbreviation M is also accepted. If an abbreviation is not used, it defaults to K
You'll want to do this in its own folder, and also if you're installing from a CD image on your hard-drive (I did) it's useful to put it in there, too.
Now install the operating system/format the disk. To do this, I launched qemu like this:
qemu -cdrom Win2kPro.iso -boot d -hda win2k.img
Win2kPro.iso is the image of my Windows 2000 Pro installation CD
-boot d tells it to boot from CD-ROM
-hda winb2k.img tells it that that file is the primary hard-drive
Now that Windows is installed, you need to get internet working. It autoconfigures its NIC with a virtual dhcp server with the IP of 10.0.2.5. You need to allow packet flow of that DHCP server, so I put these rules in my iptables config:
$IP_FROM_CLIENT_OS was set to the virtual dhcp server's ip: 10.0.2.5
iptables -A FORWARD -d $IP_FROM_CLIENT_OS -j ACCEPT
iptables -A FORWARD -s $IP_FROM_CLIENT_OS -j ACCEPT
You'll need to make sure you have the tun/tap kernel module installed. It was, in my kernel, installed as a module by default. So all I had to do was:
You now have a /dev/net/tun device, and should have internet.
After that, I reloaded the image like this:
And the OS and internet connection were working.
/usr/local/bin/qemu -m 128 -smp 1 -boot c -hda '/home/scuzzy/Win2kPro/win2k.img'
Hope this helps someone :D