一、创建Bond
1、查看网卡信息
[root@localhost ~]# ip a[root@localhost ~]# nmcli connection showens6f0 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-ens4f0TYPE=Ethernet#PROXY_METHOD=none#NM_CONTROLLED=no#EFROUTE=yesBOOTPROTO=noneMASTER=bond0SLAVE=yesNAME=ens4f0DEVICE=ens4f0ONBOOT=yes[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens4f1TYPE=Ethernet#PROXY_METHOD=none#NM_CONTROLLED=no#EFROUTE=yesBOOTPROTO=noneMASTER=bond0SLAVE=yesNAME=ens4f1DEVICE=ens4f1ONBOOT=yes
4、手动创建bonding.conf配置文件,并将其加入系统启动项
此步骤一定要操作,否则bond创建完成后不一会就自动消失了!
[root@localhost ~]# vim /etc/modprobe.d/bonding.confalias bond0 bondingoptions 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/slavesens4f0 ens4f1
7、查看bond网卡配置和bond信息
[root@localhost ~]# nmcli connection showens6f0 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-bond0BONDING_OPTS=mode=802.3adTYPE=BondBONDING_MASTER=yesPROXY_METHOD=noneBROWSER_ONLY=noBOOTPROTO=staticDEFROUTE=yesIPV4_FAILURE_FATAL=noIPV6INIT=yesIPV6_AUTOCONF=yesIPV6_DEFROUTE=yesIPV6_FAILURE_FATAL=noIPV6_ADDR_GEN_MODE=stable-privacyNAME=bond0UUID=eb6e1a3c-ddbe-4abc-8e3a-cb9118fcabfbDEVICE=bond0ONBOOT=yes[root@localhost ~]# cat /proc/net/bonding/bond0Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)Bonding Mode: IEEE 802.3ad Dynamic link aggregationTransmit Hash Policy: layer2 (0)MII Status: upMII Polling Interval (ms): 100Up Delay (ms): 0Down Delay (ms): 0802.3ad infoLACP rate: slowMin links: 0Aggregator selection policy (ad_select): stableSystem priority: 65535System MAC address: e8:eb:d3:21:a8:78Active Aggregator Info:Aggregator ID: 1Number of ports: 4Actor Key: 21Partner Key: 1Partner Mac Address: 64:2f:c7:55:2b:c2Slave Interface: ens4f0MII Status: upSpeed: 25000 MbpsDuplex: fullLink Failure Count: 0Permanent HW addr: e8:eb:d3:21:a8:78Slave queue ID: 0Aggregator ID: 1Actor Churn State: nonePartner Churn State: noneActor Churned Count: 0Partner Churned Count: 0details 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: 61details 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: 61Slave Interface: ens4f1MII Status: upSpeed: 25000 MbpsDuplex: fullLink Failure Count: 0Permanent HW addr: e8:eb:d3:21:a8:79Slave queue ID: 0Aggregator ID: 1Actor Churn State: nonePartner Churn State: noneActor Churned Count: 0Partner Churned Count: 0details 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: 61details 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/slavesens4f0 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配置文件
[root@localhost ~]# rm -rf /etc/modprobe.d/bonding.conf
4、删除bond
[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
来源地址:https://blog.csdn.net/weixin_44728499/article/details/128167961