TOP
|
[ 录入者:admin | 时间:2007-10-28 01:56:58
| 作者: | 来源:
| 浏览:720次 ] |
qemu构建复杂的网络环境的shell脚本,需要xwindows服务端的支持。#!/bin/sh DISPLAY=192.168.1.2:0.0 export DISPLAY #============================================================================== # 0.1 0.2 2.2 2.1 # C0 -- \ /----------------\ # C2 C4 ---- C5 # C1 -- / \----- c3 ------/ 5.2 5.1 # 1.1 1.2 3.2 3.1 4.2 4.1 # #============================================================================== # # startup c2 # eth0: 172.0.0.2 # eth1: 172.1.0.2 # eth2: 172.2.0.2 # eth3: 172.3.0.2 #------------------ # route add -net 172.4/24 172.3.0.1 #--------------------------------------------------------------------------------- qemu -m 32 -boot c -hda tinybsd.img -parallel null -k en-us -localtime \ -net nic,vlan=0,macaddr=00:4c:4c:00:00:02 -net socket,vlan=0,listen=:1720 \ -net nic,vlan=1,macaddr=00:4c:4c:01:00:02 -net socket,vlan=1,listen=:1721 \ -net nic,vlan=2,macaddr=00:4c:4b:02:00:02 -net socket,vlan=2,listen=:1722 \ -net nic,vlan=3,macaddr=00:4c:4c:03:00:02 -net socket,vlan=3,listen=:1723 & sleep 25
# startup c0 # eth0: 172.0.0.1 #------------------ # route add default 172.0.0.2 #--------------------------------------------------------------------------------- qemu -m 32 -boot c -hda tinybsd.img -parallel null -k en-us -localtime \ -net nic,vlan=0,macaddr=00:4c:4c:00:00:01 -net socket,vlan=0,connect=127.0.0.1:1720 & sleep 25
# startup c1 # eth0: 172.1.0.1 #------------------ # route add default 172.1.0.2 #--------------------------------------------------------------------------------- qemu -m 32 -boot c -hda tinybsd.img -parallel null -k en-us -localtime \ -net nic,vlan=1,macaddr=00:4c:4c:01:00:01 -net socket,vlan=1,connect=127.0.0.1:1721 & sleep 25
# startup c3 # eth0: 172.3.0.1 # eth1: 172.4.0.2 #------------------ # route add -net 172.1/24 172.3.0.2 #--------------------------------------------------------------------------------- qemu -m 32 -boot c -hda tinybsd.img -parallel null -k en-us -localtime \ -net nic,vlan=3,macaddr=00:4c:4c:03:00:01 -net socket,vlan=3,connect=127.0.0.1:1723 \ -net nic,vlan=4,macaddr=00:4c:4b:04:00:02 -net socket,vlan=4,listen=:1732 & sleep 25 # startup c4 # eth0: 172.2.0.1 # eth1: 172.4.0.1 # eth2: 172.5.0.2 #------------------ # route add -net 172.1/24 172.4.0.2 # route add -net 172.0/24 172.2.0.2 #---------------------------------------------------------------------------------
cat > /tmp/qemu_ifup << eof #!/bin/sh n=\`echo \$1 | sed 's/\([a-z]*\)//g'\` /sbin/ifconfig \$1 172.5.\$n.1 netmask 255.255.255.0 eof chmod +x /tmp/qemu_ifup
qemu -m 36 -boot c -hda kdns.img -parallel null -k en-us -localtime \ -net nic,vlan=2,macaddr=00:4c:4c:02:00:01 -net socket,vlan=2,connect=127.0.0.1:1722 \ -net nic,vlan=4,macaddr=00:4c:4b:04:00:01 -net socket,vlan=4,connect=127.0.0.1:1732 \ -net nic,macaddr=00:4c:4c:05:00:02 -net tap,script=/tmp/qemu_ifup &
见:http://www.cublog.cn/u/132/showart_186879.html |
|
|
|