kvm虚拟机桥接模式上网配置

本文介绍如何配置kvm虚拟机桥接上网
首先是要在自己的debian/ubuntu上把网卡eth0设为桥接
auto eth0                                                                       
iface eth0 inet manual                                                          
                                                                                
auto br0                                                                        
iface br0 inet static                                                           
    address 10.5.0.80                                                           
    netmask 255.255.0.0                                                         
    gateway 10.5.0.67                                                           
    bridge_ports eth0                                                           
    bridge_stp off                                                              
    bridge_fd 0                                                                 
    bridge_maxwait 0


然后是关闭虚拟机,
如果你虚拟机用root装的
virsh -c qemu:///system shutdown vm0

否则
virsh -c qemu:///session shutdown vm0


配置虚拟机,
虚拟机的配置文件在$HOME/.libvirtd/qemu/vm0.xml下,这么改
    <interface type='bridge'>                                                                                                                         
      <mac address='52:54:00:48:27:68'/>                                           
      <source bridge='br0'/>                                                       
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>

然后启动虚拟机,应该能自动分配ip了

猜你喜欢

转载自luozhaoyu.iteye.com/blog/1714382