In the need to make a virtual machine, like what we see with vmware.
there are a magic tool named qemu, it ‘s a free processor emulator created by
Fabrice Bellar.
well, to setup a new machine you have to prepare a partition image named linux.img,
in this example with 1024MB.
$ qemu-img create -f qcow linux.img 1G
place your distribution cd on your media and type :
$ qemu -boot d -cdrom /dev/cdrom -hda linux.img
After completing the system operating installation you can boot from the hard disk image.
$ qemu -hda linux.img -boot c
The example above don’t setup the network.
So, we can do it as following
$ qemu -hda linux.img -net nic -net tap -boot c
create a bash script with this contenent and make it executable.
#!/usr/bin/sudo -s
set -e
tunctl -u username -t tap0
ifconfig tap0 172.20.0.1 up
export LAN=tap0
export WAN=eth0
iptables -A FORWARD -i ${LAN} -s 172.20.0.0/255.255.255.0 -j ACCEPT
iptables -A FORWARD -i ${WAN} -d 172.20.0.0/255.255.255.0 -j ACCEPT
iptables -t nat -A POSTROUTING -o ${WAN} -j MASQUERADE
echo 1 > /proc/sys/net/ipv4/ip_forward
for f in /proc/sys/net/ipv4/conf/*/rp_filter ; do echo 1 > $f ; done
run it and enjoy !
