Linux Bonding 的驅動程式最早是在 Lnux Kernel 2.0 由 Donald Becker 提供 Bonding 的核心修補檔案,至目前已逐漸成為 Linux Kernel 正式套件之一。
Channel Bonding 一般又稱呼為 Port Trunking,是將兩張以上的網路卡合併成為一張邏輯的網路界面來使用,主要功能有以下兩項:
頻寬輸入與輸出倍增:安裝兩張以上網路卡並搭配 Bonding 的配置,主機到 SWITCH 設備端的網路頻寬,可以倍增。
網路線路與設備備援:提供網路卡至 SWITCH 的備援,可以避免機器本身網路卡故障或者是網路線斷裂導致網路不通的問題。
Bonding 無法達成的功能:
無法提供不同網段的頻寬合併,網路卡必須在同一網段中。
SWITCH 當機,線路連接正常,指 SWITCH 及網路卡兩端 link 燈顯示正常,雖然網路中斷,但因 Bonding 驅動程式無法正確偵測到,網路線路與設備備援功能將失效,不會有切換動作。
LEAF 中設定 Channel Bonding 步驟
下載 ifenslav.lrp http://leaf.sourceforge.net/bering-uclibc/index.php?module=pagemaster&PAGE_user_op=view_page&PAGE_id=12&MMN_position=32:32
設定範例:
module 載入 bonding.o 位於 Bering-uClibc_modules_xxxx.tar\2.4.33\kernel\drivers\net\bonding\bonding.o
insmod bonding mode=1 miimon=50
ip addr add 192.168.1.1/24 dev bond0
ip link set bond0 up
ifenslave bond0 eth0 eth1
bonding 參數說明:
mode:Bonding 模式(1~6)miimon:每隔多久 (milli-seconds) 偵測一次狀態
mode:Bonding 模式相關說明
mode=0 (balance-rr) Round-robin policy:交換器需設定 trunk 支援,具容錯功能,其中一張 Slave 網卡失效仍可持續運作。
Transmit packets in sequential order from the first available slave through the last. This mode provides load balancing and fault tolerance.
mode=1 (active-backup) Active-backup policy:不需交換器支援,同一時間只有單一 Slave 網卡運作,Active Slave 網卡失效時自動啟用次一順位 Slave 網卡。
Only one slave in the bond is active. A different slave becomes active if, and only if, the active slave fails. The bond's MAC address is externally visible on only one port (network adapter) to avoid confusing the switch. This mode provides fault tolerance. The primary option affects the behavior of this mode.
mode=2 (balance-xor) XOR policy:
Transmit based on [(source MAC address XOR'd with destination MAC address) modulo slave count]. This selects the same slave for each destination MAC address. This mode provides load balancing and fault tolerance.
mode=3 (broadcast) Broadcast policy: 具容錯功能,所有 Slave 網卡一齊收送網路封包,其中一張 Slave 網卡失效仍可持續運作
transmits everything on all slave interfaces. This mode provides fault tolerance.
mode=4 (802.3ad) IEEE 802.3ad Dynamic link aggregation.
Creates aggregation groups that share the same speed and duplex settings. Utilizes all slaves in the active aggregator according to the 802.3ad specification.
Pre-requisites:
1. Ethtool support in the base drivers for retrieving the speed and duplex of each slave.
2. A switch that supports IEEE 802.3ad Dynamic link aggregation.
Most switches will require some type of configuration to enable 802.3ad mode.
mode=5 (balance-tlb) Adaptive transmit load balancing(輸出自動負載平衡): 不需交換器支援及設定,具容錯功能,傳入由 Current Active Slave 負責,其中一張 Slave 網卡失效仍可持續運作
channel bonding that does not require any special switch support. The outgoing traffic is distributed according to the current load (computed relative to the speed) on each slave. Incoming traffic is received by the current slave. If the receiving slave fails, another slave takes over the MAC address of the failed receiving slave.
Prerequisite:
Ethtool support in the base drivers for retrieving the speed of each slave.
mode=6 (balance-alb) Adaptive load balancing(輸出/入皆自動負載平衡): 具容錯功能,不需交換器支援及設定,Slave 網卡 driver 需支援 setting hardware address 功能,其中一張 Slave 網卡失效仍可持續運作。
includes balance-tlb plus receive load balancing (rlb) for IPV4 traffic, and does not require any special switch support. The receive load balancing is achieved by ARP negotiation. The bonding driver intercepts the ARP Replies sent by the local system on their way out and overwrites the source hardware address with the unique hardware address of one of the slaves in the bond such that different peers use different hardware addresses for the server.
相關檔案:
/proc/net/bond0/info
/proc/net/bond1/info
….
/proc/net/bondn/info
/etc/modules.conf 設定範例
alias bond0 bonding
options bond0 -o bond0 mode=0 miimon=100
alias bond1 bonding
options bond1 -o bond1 mode=1 miimon=100
參考文件:
http://jaist.dl.sourceforge.net/sourceforge/bonding/bonding.txt