配置之前首先后安装 bridge-utils
编辑文件:
vim /etc/network/interface
- auto lo
- iface lo inet loopback
- iface eth0 inet manual
- auto br0
- iface br0 inet static
- address 192.168.1.104
- netmask 255.255.255.0
- network 192.168.1.0
- broadcast 192.168.1.255
- gateway 192.168.1.1
- dns-nameservers 192.168.1.1
- bridge_ports eth0
- bridge_stp off
- bridge_fd 0
- bridge_maxwait 0
注意,如果没有配dns-nameservers 将没法ping通外网
重启网络:/etc/init.d/networking restart
用libvirt启动虚拟机,虚拟机使用桥接方式配置,vnc连接到虚拟机时,如果vnc 没法连接到虚拟机,检查 /etc/libvirt/qemu.conf文件 vnc_listen="0.0.0.0"是否启用。启用之后,原有的虚拟机需要重启,libvirt 也要重启。
如果是配置静态IP:
auto eth0
iface eth0 inet static
address 192.168.0.58
gateway 192.168.0.254
netmask 255.255.255.0
network 192.168.0.255
dns-nameservers 192.168.0.254
iface eth0 inet static
address 192.168.0.58
gateway 192.168.0.254
netmask 255.255.255.0
network 192.168.0.255
dns-nameservers 192.168.0.254