在Ubuntu环境中qemu-kvm网桥的配置

在文件/etc/network/interfaces中添加以下内容

auto lo
iface lo inet loopback

#auto eth0
#iface eth0 inet manual

auto br0 
iface br0 inet dhcp
bridge_ports  all # eth0 tap0 
bridge_fd 9
bridge_hello 2
bridge_maxage 12
bridge_stp off 

如果使用virsh启动虚拟机,以下可以不添加,同时上述bridge_ports  all  改为bridge_ports  eth0  
auto tap0
iface tap0 inet manual
pre-up tunctl -t tap0 -u username #将username修改为自己的用户名即可
pre-up ifconfig tap0 0.0.0.0 promisc up
post-up brctl addif  br0 tap0

重启网络或者重启宿主机
使用qemu-kvm启动虚拟机时加入参数-net nic -net tap,ifname=tap0,script=no,downscript=no即可

桥接的shell脚本配置方式:https://github.com/starrytale/kvm_bridge_file

原文地址:https://www.cnblogs.com/starrytales/p/6186136.html