centos7 bond双网卡

与世无争的帅哥 提交于 2020-01-08 03:51:29

[root@pay network-scripts]# cat ifcfg-bond0 |grep -v \#
TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="static"
IPADDR="192.168.67.111"
NETMASK="255.255.255.0"
GATEWAY="192.168.67.2"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
DEVICE="bond0"
ONBOOT="yes"
BONDING_OPTS="miimon=100 mode=1"
[root@pay network-scripts]# cat ifcfg-ens38 |grep -v \#
TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="static"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
DEVICE="ens38"
MASTER=bond0
SLAVE=yes
[root@pay network-scripts]# cat ifcfg-ens39 |grep -v \#
TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="static"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
DEVICE="ens39"
MASTER=bond0
SLAVE=yes

 

 

[root@pay network-scripts]# service network restart 

 

[root@pay ~]# ip a |egrep 'bond|ens38|ens39'
4: ens38: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP qlen 1000
5: ens39: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP qlen 1000
8: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP qlen 1000
inet 192.168.67.111/24 brd 192.168.67.255 scope global bond0
[root@pay ~]# 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: ens39
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: ens38
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 1
Permanent HW addr: 00:0c:29:52:f7:35
Slave queue ID: 0

Slave Interface: ens39
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:0c:29:52:f7:3f
Slave queue ID: 0

 

 

 总结:   TYPE="Ethernet" 不能设置为bond ,   也不用设置啥  /etc/modprobe.d/bonding.conf  添加  alias bond0 bonding

 

测试:!!!!!!!!!!!!!!!!!!

停掉其中1个网卡

[root@pay network-scripts]# ifdown ifcfg-ens39
Device 'ens39' successfully disconnected.

只剩下38

[root@pay ~]# 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: ens38
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: ens38
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 1
Permanent HW addr: 00:0c:29:52:f7:35
Slave queue ID: 0

 

[root@pay ~]# ifup ens39
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/28)

恢复39

[root@pay ~]# 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: ens38
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: ens38
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 2
Permanent HW addr: 00:0c:29:52:f7:35
Slave queue ID: 0

Slave Interface: ens39
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:0c:29:52:f7:3f
Slave queue ID: 0

关掉38

[root@pay ~]# ifdown ens38
Device 'ens38' successfully disconnected.

[root@pay ~]# 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: ens39
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: ens39
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:0c:29:52:f7:3f
Slave queue ID: 0

 

ifdown bond0后再ifup bond0 需要重启网卡才能恢复

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!