Sunday, September 16, 2007

Qemu with networking

1.Building the enviorenment:
  • apt-get install qemu
  • apt-get install uml-utilities
  • apt-get install bridge-utils
2.Configuring HostOS:
  • modprobe tun
  • mkdir /dev/net
  • mknod /dev/net/tun c 10 200
  • tunctl
  • brctl addbr br0
  • create /etc/qemu-ifup file and make it executable
#!/bin/sh
echo "Executing /etc/qemu-ifup"
echo "Bringing up $1 for bridged mode..."
ifconfig $1 0.0.0.0 promisc up
echo "Adding $1 to br0..."
brctl addif br0 $1
sleep 2

  • Create qemu-start.sh script and make it executable
#!/bin/bash

ARGS="-hda /dev/sda -boot c -net nic,vlan=0 -net tap,vlan=0,ifname=tap0,script=/etc/qemu-ifup -m 256 -localtime"
echo "Loading kqemu kernel module..."
modprobe kqemu
echo "...."
echo "Starting QEMU with..."
echo $ARGS
echo "...."
echo "Setting memory"
umount /dev/shm
mount -t tmpfs -o size=272m none /dev/shm
exec qemu $ARGS

  • host ip is => 192.248.17.221
  • ifconfig tap0 192.248.17.222 up
  • Start qemu with qemu-start.sh
3.Configuring GuestOS:
  • ifconfig eth0 192.248.17.223/24 up
  • route add default gw 192.248.17.222
  • ping 192.248.17.222
4.References:
  • http://compsoc.dur.ac.uk/~djw/qemu.html
  • http://ubuntuforums.org/showthread.php?t=179472
  • http://wiki.openvz.org/Using_private_IPs_for_Hardware_Nodes


No comments:

Post a Comment