---
title: （可选）配置Bond4
description: 如果需要搭建“Docker+Bond4+IPVLAN”的组网环境，请参考本章节配置Bond4。如果基于物理机、容器、虚拟机直通网络环境使能，请跳过此章节。
url: "https://www.hikunpeng.com/document/detail/zh/boostdb/systemcollaborativeoptimization/dso/kunpeng_redis_dlj_zn_64_006.html"
---

# （可选）配置Bond4

如果需要搭建“Docker+Bond4+IPVLAN”的组网环境，请参考本章节配置Bond4。如果基于物理机、容器、虚拟机直通网络环境使能，请跳过此章节。

Bond4是网络接口绑定（Network Interface Bonding）中的模式4，也称为IEEE 802.3ad动态链路聚合或LACP（Link Aggregation Control Protocol，链路聚合控制协议）。这种模式通过将多个物理网络接口组合成一个逻辑接口来提升带宽和提供冗余。配置Bond4需同时修改Server端和交换机配置，需提前确认Server端组Bond4的两张网卡对应的交换机的物理接口及交换机IP地址。

#### 交换机动态LACP配置

1. 登录交换机。
2. 查看交换机上所有可用的物理接口。
  1 display interface brief

  如上图所示，检查Server端组Bond4的两张网卡eth1和eth2对应交换机上的端口状态为up且没有在Eth-Trunk组内。下文以25GE 1/0/33和25GE 1/0/34端口为例进行Bond4配置。

3. 创建聚合组Eth-Trunk 12并将物理接口25GE 1/0/33和25GE 1/0/34加入Eth-Trunk 12。
  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 system-view interface Eth-Trunk 12 mode lacp-dynamic trunkport 25GE 1/0/33 trunkport 25GE 1/0/34 commit quit interface 25GE 1/0/33 eth-trunk 12 commit quit interface 25GE 1/0/34 eth-trunk 12 commit quit


#### Server端配置

登录Server端，执行以下操作将两张网卡eth1和eth2组成Bond4。


1. 登录Server端。
2. 断开eth1和eth2网卡的网络连接。
  1 2 nmcli con down eth1 nmcli con down eth2

3. 备份eth1网卡和eth2网卡配置文件“/etc/sysconfig/network-scripts/ifcfg-eth1”和“/etc/sysconfig/network-scripts/ifcfg-eth2”，并删除原文件。
  1 2 3 4 5 cd /etc/sysconfig/network-scripts cp ifcfg-eth1 ifcfg-eth1.bak cp ifcfg-eth2 ifcfg-eth2.bak rm -rf ifcfg-eth1 rm -rf ifcfg-eth2

4. 将eth1和eth2网卡组成Bond4，且使其支持802.3ad协议。
  1 2 3 4 5 6 nmcli con add type bond con-name bond4 ifname bond4 mode 802.3ad nmcli con add type bond-slave ifname eth1 master bond4 nmcli con add type bond-slave ifname eth2 master bond4 nmcli con up bond-slave-eth1 nmcli con up bond-slave-eth2 nmcli con up bond4

5. 修改Bond4的配置文件。

  a. 打开ifcfg-bond4文件。
    1 vi /etc/sysconfig/network-scripts/ifcfg-bond4

  b. 添加IP地址，将“BOOTPROTO=dhcp”改成“BOOTPROTO=none”，IP地址和子网掩码修改成实际使用的地址和掩码。
    1 2 3 IPADDR=192.168.xx.xx NETMASK=255.255.255.0 BOOTPROTO=none

  c. 按“Esc”键退出编辑模式，输入:wq!，按“Enter”键保存退出文件。
6. 重启网络服务和Bond4。
  1 2 3 service NetworkManager restart nmcli con down bond4 nmcli con up bond4

7. 查看Bond4的网络信息。
  1 2 ip a | grep -C 5 bond4 ip a

8. 查看Bond4状态。
```
cat /proc/net/bonding/bond4
```

满足以下条件则Bond4配置正确：

  - Bonding Mode为IEEE 802.3ad Dynamic link aggregation。
  - MII Status状态为up。
  - 服务器间使用Bond4 IP，服务器之间可以互相连接。

#### 交换机侧检查Bond4配置

在Server端配置完成Bond4并检查配置正确后，在交换机侧查看Eth-Trunk 12。```
display eth-trunk 12
```


满足以下条件则表示Bond4配置正确：

- Working Mode为Dynamic。
- Operating Status状态为up。
- Number Of Up Ports In Trunk为2，且在回显中有25GE 1/0/33和25GE 1/0/34两个端口的相关信息。
