1.vi /etc/libvirt/qemu/networks/qybr.xml
<network>
<name>qybr10</name>
<uuid>80eab63e-2b1e-4844-b237-0bb3288c39c3</uuid>
<forward mode='nat'/>
<bridge name='qybr10' stp='on' delay='0' />
<ip address='10.10.10.1' netmask='255.255.255.0'>
<dhcp>
<range start='10.10.10.2' end='10.10.10.254' />
</dhcp>
</ip>
</network>
2.virsh net-define /etc/libvirt/qemu/networks/qybr10.xml
virsh net-autostart qybr10
virsh net-start qybr10
3.vi /etc/libvirt/qemu/QianYuSrvZTE_IVR.xml
<type arch='x86_64' machine='pc-0.12'>hvm</type>
<boot dev='hd'/>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<clock offset='localtime'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<emulator>/usr/bin/kvm</emulator>
<disk type='file' device='disk'>
<driver name='qemu' type='raw'/>
<source file='/var/lib/libvirt/images/QianYuSrvZTE_IVR.img'/>
//指定img文件位置
<target dev='hda' bus='ide'/>
</disk>
<disk type='file' device='cdrom'>
<driver name='qemu' type='raw'/>
<source file='/media/iso/zh-hans_windows_xp_professional_with_service_pack_3_x86_cd_vl_x14-74070.iso'/>
<target dev='hdc' bus='ide'/>
<readonly/>
</disk>
<interface type='bridge'>
<mac address='52:54:00:70:a2:e4'/>
<source bridge='qybr10'/>
</interface>
<console type='pty'>
<target port='0'/>
</console>
<console type='pty'>
<target port='0'/>
</console>
<input type='tablet' bus='usb'/>
<input type='mouse' bus='ps2'/>
<graphics type='vnc' port='-1' autoport='yes'/>
<video>
<model type='cirrus' vram='9216' heads='1'/>
</video>
</devices>
</domain>
4. create a new VM:
virsh define /etc/libvirt/qemu/QianYuSrvZTE_IVR.xml
virsh start QianYuSrvZTE_IVR
5.port forwarding: 10180
iptables -t nat -I PREROUTING -p tcp --dport 10180 -j DNAT --to-destination 10.10.10.xx:80
iptables -I FORWARD -m state -d 10.10.10.0/24 --state NEW,RELATED,ESTABLISHED -j ACCEPT
注:子网建立完之后如何进行删除 virsh net-destroy /etc/libvirt/qemu/networks/xxx
virsh net-undefine /etc/libvirt/qemu/networks/ xxx
KVM中新建虚拟子网
猜你喜欢
转载自464772913.iteye.com/blog/1439942
今日推荐
周排行