Launch Windows XP with Qemu
# Starts up QEmu with various options # Variables set -o errexit SOUND="-soundhw es1370" MEMORY="-m 330" TIME="-localtime" IMGPATH="/mnt/data/virtual/xp" IMG=$1 USERID=`whoami` # need to make sure we have read/write access to the device at /dev/net/tun echo "Using sudo too to setup /dev/net/tun..." sudo chown root:$USERID /dev/net/tun sudo chmod g+rw /dev/net/tun # now be sure that IP forwarding and masquerading are good to go echo "Need root password to setup IP forwarding..." su -c "echo '1' > /proc/sys/net/ipv4/ip_forward" echo "Done being root..." sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE # Create tap interface so that the script /etc/qemu-ifup can bridge it # before qemu starts echo "Using sudo to setup the tap interface..." IFACE=`sudo tunctl -b -u $USERID` NET="-net nic,vlan=0 -net tap,vlan=0,ifname=$IFACE,script=/etc/qemu-ifup" # QEmu start qemu ${SOUND} ${TIME} ${MEMORY} ${IMG} ${NET} -usb # QEmu has stopped - no longer using tap interface sudo tunctl -d $IFACE &> /dev/null # user no longer needs read/write on /dev/net/tun sudo chown root:root /dev/net/tun
after script execution I run this 'sudo ifconfig tap0 192.168.1.6'
when the script is finished I run this 'sudo tunctl -d tap0'