红联Linux门户
Linux帮助

解决centos的virt-manager无法创建network interface问题

发布时间:2016-03-04 10:41:44来源:linux网站作者:chenyulancn

新安装的centos系统,本以为对libvirt尤其对网络支持的会很好,结果还是在创建network interface出错,启动时提示:Conncetion activation failed: Failed to determine connection’s virtual interface name、Connection activation failed: Master connection not found or invalid错误,无奈搜罗整理各种解决办法。


1.首先安装 bridge-utils,也有可能你的系统安装时已经安装上了

yum install bridge-utils


2.关闭NetworkManager,启动network

网络被NetworkManager(即右上角的网络图标)接管,需要把它停掉,并禁止开机启动。

chkconfig NetworkManager off
chkconfig network on
service NetworkManager stop
service network start


3.进入文件夹(root权限)

cd /etc/sysconfig/network-scripts


4.添加配置文件

如果网络在使用先关闭

ifdown eth0

添加配置文件,新建名为 ifcfg-eth0的配置文件,添加内容如下:

DEVICE=eth0
ONBOOT=yes
BRIDGE=br0

备注:br0与后续要创建的要对应一直,后需要创建 ifcfg-br0

添加配置文件,新建名为ifcfg-br0的配置文件,添加内容如下(如果使用dhcp的话使用如下配置):

DEVICE=br0
ONBOOT=yes
TYPE=Bridge
BOOTPROTO=dhcp
STP=on
DELAY=0

如果使用静态ip需要添加ip、网关、dns信息,具体如下:

DEVICE=br0
ONBOOT=yes
TYPE=Bridge
BOOTPROTO=static
IPADDR=xx.xx.xx.xx
GATEWAY=xx.xxx.xxx.xx
DNS1=xx.xx.xx.xx
STP=on
DELAY=0


5.启动设备

ifup eth0
ifup br0

或者重启网络

/etc/init.d/network restart


6.有人说如果是多网卡 可能还需在文件 /etc/sysctl.conf  添加如下配置(结果如何尚未验证)

vi /etc/sysctl.conf

net.ipv4.conf.em1.rp_filter = 0
net.ipv4.conf.em2.rp_filter = 0
net.ipv4.conf.br0.rp_filter = 0
net.ipv4.conf.all.rp_filter = 0


本文永久更新地址:http://www.linuxdiyf.com/linux/18607.html