在Centos7上玩KVM的话一定要配置网桥的:
[root@localhost nb]# ls /etc/sysconfig/network-scripts ifcfg-8866 ifdown ifdown-isdn ifdown-TeamPort ifup-ib ifup-post ifup-tunnel network-functions-ipv6 ifcfg-br0 ifdown-bnep ifdown-post ifdown-tunnel ifup-ippp ifup-ppp ifup-wireless ifcfg-CCAP_guest ifdown-eth ifdown-ppp ifup ifup-ipv6 ifup-routes init.ipv6-global ifcfg-enp0s25 ifdown-ib ifdown-routes ifup-aliases ifup-isdn ifup-sit keys-8866 ifcfg-iPak ifdown-ippp ifdown-sit ifup-bnep ifup-plip ifup-Team keys-iPak ifcfg-lo ifdown-ipv6 ifdown-Team ifup-eth ifup-plusb ifup-TeamPort network-functions
上面的是配置好的,可以看到新增的文件ifcfg-br0
接下来看看ifcfg-br0 和ifcfg-enp0s25网卡文件:
# cat /etc/sysconfig/network-scripts/ifcfg-br0 TYPE=Bridge BOOTPROTO=dhcp DEFROUTE=yes PEERDNS=yes PEERROUTES=yes IPV4_FAILURE_FATAL=no DEVICE=br0 ONBOOT=yes # cat /etc/sysconfig/network-scripts/ifcfg-enp0s25 TYPE=Ethernet BOOTPROTO=dhcp DEFROUTE=yes PEERDNS=yes PEERROUTES=yes IPV4_FAILURE_FATAL=no IPV6INIT=yes IPV6_AUTOCONF=yes IPV6_DEFROUTE=yes IPV6_PEERDNS=yes IPV6_PEERROUTES=yes IPV6_FAILURE_FATAL=no IPV6_ADDR_GEN_MODE=stable-privacy NAME=enp0s25 UUID=cfe5e123-26a1-4f1d-bcd0-ec8a7a91c82f DEVICE=enp0s25 ONBOOT=yes BRIDGE=br0 #只是增加 了这么一条!!!
重启网卡enp0s25(每个机器的名子不同)
ifdown enp0s25 #先关闭然后重启网卡 # systemctl restart network 查看成功后的ip: [root@localhost nb]# ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: enp0s25: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP qlen 1000 link/ether 54:xx:75:4e:37:d9 brd ff:ff:ff:ff:ff:ff 3: wlp4s0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000 link/ether 02:d7:e5:72:e5:c8 brd ff:ff:ff:ff:ff:ff 5: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN qlen 1000 link/ether 52:54:x0:fe:e5:29 brd ff:ff:ff:ff:ff:ff inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0 valid_lft forever preferred_lft forever 6: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN qlen 1000 link/ether 52:xx:00:fe:e5:29 brd ff:ff:ff:ff:ff:ff 7: vnet0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 1000 link/ether fe:54:00:d6:81:e8 brd ff:ff:ff:ff:ff:ff inet6 fe80::fc54:ff:fed6:81e8/64 scope link valid_lft forever preferred_lft forever 8: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP qlen 1000 link/ether 54:ee:75:4e:37:d9 brd ff:ff:ff:ff:ff:ff inet 10.100.0.19/24 brd 10.100.0.255 scope global dynamic br0 #可以看到ip valid_lft 86368sec preferred_lft 86368sec inet6 fe80::56ee:75ff:fe4e:37d9/64 scope link valid_lft forever preferred_lft forever
查看网桥:
# brctl show bridge name bridge id STP enabled interfaces br0 8000.54ee754e37d9 no enp0s25 virbr0 8000.525400fee529 yes virbr0-nic
来源:https://www.cnblogs.com/bass6/p/6775398.html