將多張實體網卡聚合為單一邏輯介面 (bond0),提升頻寬、實現冗余備援。Linux 核心 bonding 模組支援 7 種模式,本文以模式 1 (主備) 為例詳解配置流程。
vi /etc/sysconfig/network-scripts/ifcfg-bond0 DEVICE=bond0 IPADDR=192.168.1.2 NETMASK=255.255.255.0 GATEWAY=192.168.1.1 DNS=8.8.8.8 ONBOOT=yes BOOTPROTO=none USERCTL=no
vi /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth0 USERCTL=no ONBOOT=yes MASTER=bond0 SLAVE=yes BOOTPROTO=none HWADDR=00:15:17:CC:FC:35 # eth1 同理,DEVICE=eth1、HWADDR 對應實際 MAC
vi /etc/modprobe.conf # 或 /etc/modules.conf alias bond0 bonding options bond0 miimon=100 mode=1
miimon=100:每 100ms 檢測鏈路狀態 (僅監測本端至交換機)mode=1:Active-Backup 主備模式 (冗余)vi /etc/rc.d/rc.local ifenslave bond0 eth0 eth1 route add -net 192.168.1.0 netmask 255.255.255.0 bond0 # 視需求添加
modprobe bonding service network restart less /proc/net/bonding/bond0 # 確認 Active/Backup 狀態 ifconfig # 僅顯示 bond0 IP,eth0/eth1 無 IP
| 模式 | 名稱 | 特性 | 交換機需求 |
|---|---|---|---|
| 0 | balance-rr | 輪詢負載均衡 | 需 LACP/靜態聚合 |
| 1 | active-backup | 主備冗余 | 無 |
| 2 | balance-xor | XOR 雜湊負載均衡 | 需 LACP |
| 3 | broadcast | 全傳冗余 | 無 |
| 4 | 802.3ad | 動態 LACP 聚合 | 需 LACP |
| 5 | balance-tlb | 適應性傳輸負載均衡 | 無 |
| 6 | balance-alb | 適應性負載均衡 (含 ARP 協商) | 無 |