使用virsh-install安装虚拟机后,虚拟机不可以上网
第一步:主机上配置网桥
cp ifcfg-eno16777736 /tmp/
cp ifcfg-eno16777736 ifcfg-br0
修改两配置网卡的信息
[root@openstack network-scripts]# cat ifcfg-eno16777736 TYPE=Ethernet BOOTPROTO=static IPADDR=192.168.12.100 NETMASK=255.255.255.0 GATEWAY=192.168.12.2 DEFROUTE=yes PEERDNS=yes PEERROUTES=yes NAME=eno16777736 UUID=1da830c0-9692-4176-8639-da16a8bfe8cc DEVICE=eno16777736 ONBOOT=yes BRIDGE=br0 DNS=114.114.115.115 [root@openstack network-scripts]# cat ifcfg-br0 TYPE=Bridge BOOTPROTO=dhcp DEFROUTE=yes PEERDNS=yes PEERROUTES=yes NAME=br0 DEVICE=br0 ONBOOT=yes DNS=114.114.115.115
第二步:修改xml配置信息,type,bridge
<interface type='bridge'> <mac address='52:54:00:50:b4:d0'/> <source bridge='br0'/> <model type='virtio'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
第三步:修改虚拟机的网卡信息
root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0 TYPE=Ethernet BOOTPROTO=static IPADDR=192.168.12.51 GATEWAY=192.168.12.2 NETMASK=255.255.255.0 DEFROUTE=yes PEERROUTES=yes NAME=eth0 UUID=56b0f1bd-a0ef-4c89-89ea-b89355596cf1 DEVICE=eth0 ONBOOT=yes
重启网卡,在主机上shutdown,然后在start虚拟机
第四步:修改DNS,验证是否可以上网