模式 | 名称 | 特点 | 适用场景 |
mode 0 | balance-rr | 轮询,负载均衡(需交换机支持聚合) | 吞吐量最大化 |
mode 1 | active-backup | 主备,高可用 | 链路冗余 |
mode 2 | balance-xor | 基于哈希的负载均衡 | 负载均衡 |
mode 4 | 802.3ad (LACP) | 动态链路聚合(需交换机支持 LACP) | 高吞吐+冗余 |
mode 5 | balance-tlb | 自适应传输负载均衡 | 出口带宽均衡 |
mode 6 | balance-alb | 自适应负载均衡 | 双向带宽均衡 |
eth0、eth1)nmcli 命令配置。# 创建名为 bond0 的 Bond 连接(mode 1: 主备模式)nmcli connection add type bond \\con-name bond0 \\ifname bond0 \\bond.options "mode=active-backup,miimon=100"# LACP 模式(mode 4,需要交换机配置)nmcli connection add type bond \\con-name bond0 \\ifname bond0 \\bond.options "mode=802.3ad,miimon=100,lacp_rate=fast"
# 将 eth0 添加为 bond0 的 slavenmcli connection add type ethernet \\con-name bond0-slave-eth0 \\ifname eth0 \\master bond0# 将 eth1 添加为 bond0 的 slavenmcli connection add type ethernet \\con-name bond0-slave-eth1 \\ifname eth1 \\master bond0
# 配置静态 IPnmcli connection modify bond0 \\ipv4.addresses "192.168.1.100/24" \\ipv4.gateway "192.168.1.1" \\ipv4.dns "8.8.8.8,114.114.114.114" \\ipv4.method manual# 或配置 DHCPnmcli connection modify bond0 ipv4.method auto
# 启用 slave 连接nmcli connection up bond0-slave-eth0nmcli connection up bond0-slave-eth1# 启用 Bond 连接nmcli connection up bond0
# 禁用 eth0、eth1 的独立连接(防止 IP 冲突)nmcli connection modify eth0 connection.autoconnect nonmcli connection modify eth1 connection.autoconnect no
vim /etc/NetworkManager/system-connections/bond0.nmconnection 文件,修改 type = bond。[connection]id=bond0type=bondinterface-name=bond0autoconnect=yes[bond]mode=active-backupmiimon=100[ipv4]method=manualaddress1=192.168.1.100/24,192.168.1.1dns=8.8.8.8;114.114.114.114;[ipv6]method=ignore
[connection]id=bond0-slave-eth0type=ethernetinterface-name=eth0master=bond0slave-type=bondautoconnect=yes
nmcli connection reloadnmcli connection up bond0
# 查看 Bond 接口状态cat /proc/net/bonding/bond0# 查看网络连接状态nmcli connection show# 验证 IP 地址ip addr show bond0# 查看 Bond 成员状态ip link show
/proc/net/bonding/bond0 输出示例(active-backup 模式):Ethernet Channel Bonding Driver: v5.15.0Bonding Mode: fault-tolerance (active-backup)Primary Slave: eth0 (primary_reselect failure)Currently Active Slave: eth0MII Status: upMII Polling Interval (ms): 100Up Delay (ms): 0Down Delay (ms): 0Slave Interface: eth0MII Status: upSpeed: 1000 MbpsDuplex: fullLink Failure Count: 0Permanent HW addr: xx:xx:xx:xx:xx:xxSlave queue ID: 0Slave Interface: eth1MII Status: upSpeed: 1000 MbpsDuplex: fullLink Failure Count: 0Permanent HW addr: xx:xx:xx:xx:xx:xxSlave queue ID: 0
nmcli connection modify bond0 bond.options "mode=802.3ad,miimon=100,xmit_hash_policy=layer3+4"
layer3+4 基于 IP 和端口进行哈希,能更均匀地分配不同连接的流量。nmcli connection show eth0 | grep autoconnect
ls /etc/NetworkManager/system-connections/nmcli connection reloadnmcli connection show
文档反馈