1818IP-服务器技术教程,云服务器评测推荐,服务器系统排错处理,环境搭建,攻击防护等

当前位置:首页 - Linux系统 - centos - 正文

君子好学,自强不息!

centos7 bond双网卡

2023-02-25 | centos | gtxyzz | 6231°c
A+ A-

[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 需要重启网卡才能恢复

本文来源:1818IP

本文地址:https://www.1818ip.com/post/32762.html

免责声明:本文由用户上传,如有侵权请联系删除!

发表评论

必填

选填

选填

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。