基於多次生產環境實測,總結 Red Hat 系列雙網卡 Bonding 配置的關鍵前提、步驟與驗證方法,助你避開常見陷阱。
service network restart:重啟網路服務會導致 bonding 失效,甚至手動 ifenslave 也只能激活單張網卡cd /etc/sysconfig/network-scripts/
cp ifcfg-eth0 ifcfg-bond0
vi ifcfg-bond0
DEVICE=bond0
BOOTPROTO=static
IPADDR=192.168.1.100
NETMASK=255.255.255.0
BROADCAST=192.168.1.255
ONBOOT=yes
TYPE=Ethernet
實體網卡極簡配置:
# ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=none
# ifcfg-eth1
DEVICE=eth1
ONBOOT=yes
BOOTPROTO=none
vi /etc/modprobe.conf # 或 /etc/modprobe.d/bonding.conf
alias bond0 bonding
options bond0 miimon=100 mode=1
mode=1 (active-backup) 為高可用首選。
vi /etc/rc.d/rc.local
ifenslave bond0 eth0 eth1
reboot
ifconfig -a
# 確認 bond0、eth0、eth1 三者 MAC 與 IP 完全一致
外部同網段機器持續 ping bond0 IP,在雙網卡機器:
ifdown eth0 && ifup eth1ifcfg-eth0/eth1 中殘留 IPADDR/NETMASK → 衝突miimon → 無法偵測鏈路故障遵循「物理機驗證、同型號網卡、靜態配置、禁用 network restart」四原則,Bonding 高可用部署穩如磐石。