查看kernel是否支持网卡绑定
#查看是否支持网卡绑定 [root@localhost network-scripts]# lsmod | grep bonding #激活内核网卡绑定模块 [root@localhost network-scripts]# modprobe --first-time bonding [root@localhost network-scripts]# lsmod | grep bonding bonding 141566 0 #备份网卡配置文件 [root@localhost network-scripts]# cp ifcfg-ens* bak/ #修改ens32和ens36网卡配置文件让band0绑定接口为主,他们为从 [root@localhost network-scripts]# vim ifcfg-ens32 [root@localhost network-scripts]# cat ifcfg-ens32 TYPE=Ethernet BOOTPROTO=none NAME=ens32 DEVICE=ens32 ONBOOT=yes MASTER=bond0 SLAVE=yes NM_CONTROLLED=no USERCTL=NO [root@localhost network-scripts]# vim ifcfg-ens36 [root@localhost network-scripts]# cp ifcfg-ens32 ifcfg-ens36 cp:是否覆盖"ifcfg-ens36"? y [root@localhost network-scripts]# vim ifcfg-ens36 [root@localhost network-scripts]# cat ifcfg-ens36 TYPE=Ethernet BOOTPROTO=none NAME=ens36 DEVICE=ens36 ONBOOT=yes MASTER=bond0 SLAVE=yes NM_CONTROLLED=no USERCTL=NO #创建bond0绑定接口配置文件 [root@localhost network-scripts]# vim ifcfg-bond0 [root@localhost network-scripts]# cat ifcfg-bond0 DEVICE=bond0 ONBOOT=yes NM_CONTROLLED=no USERCTL=no BONDING_OPTS="mode=1 miimon=100" #mode=1是主备模式,两块从卡不同时生效 BOOTPROTO=static IPADDR=192.168.200.132 NETMASK=255.255.255.0 #重新启动网络服务 [root@localhost ~]# service network restart #查看bond0绑定接口 [root@localhost ~]# ifconfig bond0 bond0: flags=5187<UP,BROADCAST,RUNNING,MASTER,MULTICAST> mtu 1500 inet 192.168.200.132 netmask 255.255.255.0 broadcast 192.168.200.255 inet6 fe80::20c:29ff:fe96:3ac5 prefixlen 64 scopeid 0x20<link> ether 00:0c:29:96:3a:c5 txqueuelen 1000 (Ethernet) RX packets 186 bytes 16691 (16.2 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 122 bytes 22238 (21.7 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 #查看bond0详细信息 [root@localhost ~]# cat /proc/net/bonding/bond0 Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011) Bonding Mode: fault-tolerance (active-backup) #mode=1的模式==>主被动模式 Primary Slave: None Currently Active Slave: ens32 #当前活动中的网卡ens32 MII Status: up MII Polling Interval (ms): 100 Up Delay (ms): 0 Down Delay (ms): 0 Slave Interface: ens32 MII Status: up Speed: 1000 Mbps Duplex: full Link Failure Count: 0 Permanent HW addr: 00:0c:29:96:3a:c5 Slave queue ID: 0 Slave Interface: ens36 MII Status: up Speed: 1000 Mbps Duplex: full Link Failure Count: 0 Permanent HW addr: 00:0c:29:96:3a:cf Slave queue ID: 0测试绑定中的网卡:
我们断开ens32的网卡
[root@localhost ~]# cat /proc/net/bonding/bond0 Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011) Bonding Mode: fault-tolerance (active-backup) Primary Slave: None Currently Active Slave: ens36 #ens36被启动了 MII Status: up MII Polling Interval (ms): 100 Up Delay (ms): 0 Down Delay (ms): 0 Slave Interface: ens32 MII Status: down #ens32 down了 Speed: Unknown Duplex: Unknown Link Failure Count: 1 Permanent HW addr: 00:0c:29:96:3a:c5 Slave queue ID: 0 Slave Interface: ens36 MII Status: up Speed: 1000 Mbps Duplex: full Link Failure Count: 1 Permanent HW addr: 00:0c:29:96:3a:cf Slave queue ID: 0我们用windows ping KVM宿主机,仍然能通
实操(2):搭建bond的KVM网桥
#验证网桥virbr1状态 [root@localhost ~]# brctl show bridge name bridge id STP enabled interfaces virbr0 8000.52540079e341 yes virbr0-nic vnet0 vnet1 virbr1 8000.000c29963ac5 no bond0 [root@localhost ~]# ifconfig bond0 bond0: flags=5187<UP,BROADCAST,RUNNING,MASTER,MULTICAST> mtu 1500 inet6 fe80::20c:29ff:fe96:3ac5 prefixlen 64 scopeid 0x20<link> ether 00:0c:29:96:3a:c5 txqueuelen 1000 (Ethernet) RX packets 3717 bytes 425857 (415.8 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 7004 bytes 12720203 (12.1 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 [root@localhost ~]# ifconfig virbr1 virbr1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.200.132 netmask 255.255.255.0 broadcast 192.168.200.255 inet6 fe80::20c:29ff:fe96:3ac5 prefixlen 64 scopeid 0x20<link> ether 00:0c:29:96:3a:c5 txqueuelen 1000 (Ethernet) RX packets 3667 bytes 372147 (363.4 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 2354 bytes 7601615 (7.2 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0