---------------/etc/rc.local-------------------
echo "1" > /proc/sys/net/ipv4/ip_forward
#/sbin/iptables -t nat -A POSTROUTING -o eth0 -s 192.168.0.0/24 -j MASQUERADE
/sbin/iptables -t nat -A POSTROUTING -j MASQUERADE
/sbin/iptables -t nat -A PREROUTING -d 218.64.72.125 -p tcp --dport 19809 -j DNAT --to 192.168.2.2
/etc/init.d/named start
device="/dev/kqemu"
rm -f $device
mknod $device c 250 0
chmod 666 $device
/sbin/modprobe kqemu
/sbin/modprobe tun
----------------/etc/qemu-ifup----------------chmod 755
#!/bin/sh
/sbin/ifconfig $1 192.168.10.1
/sbin/route add -host 192.168.10.2 dev $1
#/sbin/route add -host 192.168.10.3 dev ${1##/*/}
#echo "1" > /proc/sys/net/ipv4/ip_forward
#/sbin/iptables -t nat -A POSTROUTING -o eth0 -s 192.168.0.0/24 -j MASQUERADE
----------------启动虚拟机-------------------
一个虚拟机启动:
qemu $home/fedora.img -net nic -net tap,vlan=0,ifname=tap0,script=/etc/qemu-ifup
虚拟机ip---对应于qemu-ifup中add -host $ip
虚拟机网关192.168.10.1
虚拟机dns 为主机ip(主机要装域名服务器/etc/init.d/named start)
多个虚拟机启动:
/etc/qemu-ifup0 ------------>#!/bin/sh
/sbin/ifconfig $1 192.168.0.1
/etc/qemu-ifup1 ------------>#!/bin/sh
/sbin/ifconfig $1 192.168.1.1
/etc/qemu-ifup2 ------------>#!/bin/sh
/sbin/ifconfig $1 192.168.2.1
qemu_setup.sh
#!/bin/sh
/usr/local/bin/qemu /home/raid/system/win2000_ser/win2k.img -net nic -net tap,script=/etc/qemu-ifup0 -localtime &
/usr/local/bin/qemu /home/raid/system/win2000_pro/win2k.img -net nic -net tap,script=/etc/qemu-ifup1 -localtime &
/usr/local/bin/qemu /home/raid/system/linux/fedora.img -net nic -net tap,script=/etc/qemu-ifup2 &
阅读(1866) | 评论(0) | 转发(0) |