一、创建Bond
1、查看网卡信息
[root@localhost ~]# ip a
[root@localhost ~]# nmcli connection show
ens6f0 0e3be75a-2638-4b05-97a0-89adaddb13c2 ethernet ens6f0
ens14f0 9ce46d12-fd50-380d-5160-a27902128ed5 ethernet ens14f0
ens14f1 f424bed9-9599-6487-9d60-f0d6f1698c64 ethernet ens14f1
ens4f0 11d1d159-e438-bc38-bba2-411145f244b4 ethernet ens4f0
ens4f1 f540b644-ada1-a879-c4aa-2566c44f1e74 ethernet ens4f1
2、设置bond
[root@localhost ~]# nmcli connection add con-name bond0 ifname bond0 type bond mode 4
[root@localhost ~]# nmcli connection show
3、将网卡绑定bond
[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens4f0
TYPE=Ethernet
#PROXY_METHOD=none
#NM_CONTROLLED=no
#EFROUTE=yes
BOOTPROTO=none
MASTER=bond0
SLAVE=yes
NAME=ens4f0
DEVICE=ens4f0
ONBOOT=yes
[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens4f1
TYPE=Ethernet
#PROXY_METHOD=none
#NM_CONTROLLED=no
#EFROUTE=yes
BOOTPROTO=none
MASTER=bond0
SLAVE=yes
NAME=ens4f1
DEVICE=ens4f1
ONBOOT=yes
4、手动创建bonding.conf配置文件,并将其加入系统启动项
此步骤一定要操作,否则bond创建完成后不一会就自动消失了!
[root@localhost ~]# vim /etc/modprobe.d/bonding.conf
alias bond0 bonding
options bond0 mode=4 miimon=200
[root@localhost ~]# sed -i '$a \ifenslave bond0 ens4f0 ens4f1' /etc/rc.d/rc.local
[root@localhost ~]# cat /etc/rc.d/rc.local
5、重启网络服务,加载bond信息
[root@localhost ~]# systemctl restart network
[root@localhost ~]# modprobe bonding
6、查看bond中的网卡
[root@localhost ~]# cat /sys/class/net/bond0/bonding/slaves
ens4f0 ens4f1
7、查看bond网卡配置和bond信息
[root@localhost ~]# nmcli connection show
ens6f0 0e3be75a-2638-4b05-97a0-89adaddb13c2 ethernet ens6f0
bond0 eb6e1a3c-ddbe-4abc-8e3a-cb9118fcabfb bond bond0
ens14f0 9ce46d12-fd50-380d-5160-a27902128ed5 ethernet ens14f0
ens14f1 f424bed9-9599-6487-9d60-f0d6f1698c64 ethernet ens14f1
ens4f0 11d1d159-e438-bc38-bba2-411145f244b4 ethernet ens4f0
ens4f1 f540b644-ada1-a879-c4aa-2566c44f1e74 ethernet ens4f1
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-bond0
BONDING_OPTS=mode=802.3ad
TYPE=Bond
BONDING_MASTER=yes
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=bond0
UUID=eb6e1a3c-ddbe-4abc-8e3a-cb9118fcabfb
DEVICE=bond0
ONBOOT=yes
[root@localhost ~]# cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)
Bonding Mode: IEEE 802.3ad Dynamic link aggregation
Transmit Hash Policy: layer2 (0)
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0
802.3ad info
LACP rate: slow
Min links: 0
Aggregator selection policy (ad_select): stable
System priority: 65535
System MAC address: e8:eb:d3:21:a8:78
Active Aggregator Info:
Aggregator ID: 1
Number of ports: 4
Actor Key: 21
Partner Key: 1
Partner Mac Address: 64:2f:c7:55:2b:c2
Slave Interface: ens4f0
MII Status: up
Speed: 25000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: e8:eb:d3:21:a8:78
Slave queue ID: 0
Aggregator ID: 1
Actor Churn State: none
Partner Churn State: none
Actor Churned Count: 0
Partner Churned Count: 0
details actor lacp pdu:
system priority: 65535
system mac address: e8:eb:d3:21:a8:78
port key: 21
port priority: 255
port number: 1
port state: 61
details partner lacp pdu:
system priority: 32768
system mac address: 64:2f:c7:55:2b:c2
oper key: 1
port priority: 32768
port number: 3
port state: 61
Slave Interface: ens4f1
MII Status: up
Speed: 25000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: e8:eb:d3:21:a8:79
Slave queue ID: 0
Aggregator ID: 1
Actor Churn State: none
Partner Churn State: none
Actor Churned Count: 0
Partner Churned Count: 0
details actor lacp pdu:
system priority: 65535
system mac address: e8:eb:d3:21:a8:78
port key: 21
port priority: 255
port number: 2
port state: 61
details partner lacp pdu:
system priority: 32768
system mac address: 64:2f:c7:55:2b:c2
oper key: 1
port priority: 32768
port number: 4
port state: 61
二、删除Bond
1、将网卡从bond中删除
[root@localhost ~]# cat /sys/class/net/bond0/bonding/slaves
ens4f0 ens4f1
[root@localhost ~]# echo -ens4f0 > /sys/class/net/bond0/bonding/slaves
[root@localhost ~]# echo -ens4f1 > /sys/class/net/bond0/bonding/slaves
[root@localhost ~]# cat /sys/class/net/bond0/bonding/slaves
2、将bonding从系统启动项中删除
[root@localhost ~]# vim /etc/rc.d/rc.local
3、删除bonding.conf配置文件文章来源:https://www.toymoban.com/news/detail-522511.html
[root@localhost ~]# rm -rf /etc/modprobe.d/bonding.conf
4、删除bond文章来源地址https://www.toymoban.com/news/detail-522511.html
[root@localhost ~]# ls /sys/class/net/
bond0 bonding_masters ens14f0 ens14f1 ens6f0 lo usb0 virbr0 virbr0-nic
注意:这里无法直接删除bond0配置文件和打开bonding_masters文件进行编辑,只能采用下述方式进行删除。
[root@localhost ~]# echo -bond0 >/sys/class/net/bonding_masters
[root@localhost ~]# rm -rf /etc/sysconfig/network-scripts/ifcfg-bond0
[root@localhost ~]# systemctl restart network
到了这里,关于CentOS中创建和删除Bond详细步骤的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!