KVM上创建VM,以及给VM建立子网

[size=x-small]以下操作都是在ubuntu10.04系统下进行的。[/size]
[size=large]1.vi /etc/libvirt/qemu/networks/qybr.xml[/size]
<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>
[size=large]2.virsh net-define /etc/libvirt/qemu/networks/qybr10.xml[/size]
virsh net-autostart qybr10
virsh net-start qybr10
[size=large]3.vi /etc/libvirt/qemu/QianYuSrvZTE_IVR.xml[/size]
<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'/>
[color=red] //指定img文件位置[/color]
<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>
[size=large]4. create a new VM:[/size]
virsh define /etc/libvirt/qemu/QianYuSrvZTE_IVR.xml
virsh start QianYuSrvZTE_IVR
[size=large]5.port forwarding: 10180[/size]
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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值