十月 2009
« 九月   十一月 »
 123
45678910
11121314151617
18192021222324
25262728293031

Linux Bonding (合併網卡) 實作

Linux Bonding (合併網卡) 實作

目的

* 網卡自動備援
* 增加傳輸頻寬
* 多網卡負載平衡

實作環境

* Fedora Core 3 Linux
* Realtek RTL8139 PCI Fast Ethernet NIC * 2 (driver: 8139too)
* LAN: 192.168.0.0/24; Linux Host: 192.168.0.1; Gateway: 192.168.0.254

環境設定

vi /etc/sysconfig/network-scripts/ifcfg-bond0

DEVICE=bond0
IPADDR=192.168.0.1
NETMASK=255.255.255.0
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=xx:xx:xx:xx:xx:xx

vi /etc/sysconfig/network-scripts/ifcfg-eth1

DEVICE=eth1
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none
HWADDR=xx:xx:xx:xx:xx:xx

vi /etc/sysconfig/network

NETWORKING=yes
HOSTNAME=myhost
GATEWAY=192.168.0.254

vi /etc/modprobe.conf

alias bond0 bonding
options bond0 miimon=100 mode=1

手動啟用 bonding (或於完成上述步驟後重新啟動電腦)

service network stop
modprobe bonding miimon=100 mode=1
ifconfig bond0 192.168.0.1 netmask 255.255.255.0
ifenslave bond0 eth0 eth1
route add default gw 192.168.0.254 dev bond0

查看 bonding 狀態

#cat /proc/net/bonding/bond0

Ethernet Channel Bonding Driver: v2.6.0 (January 14, 2004)

Bonding Mode: fault-tolerance (active-backup)
Primary Slave: none
Currently Active Slave: eth0
MII Status: up
MII Polling Internal (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: eth0
MII Status: up
Link Failure Count: 0
Permanent HW addr: xx:xx:xx:xx:xx:xx

Slave Interface: eth1
MII Status: up
Link Failure Count: 0
Permanent HW addr: xx:xx:xx:xx:xx:xx

bonding modes

數字表示     文字表示     說明
0     balance-rr     [Loading balance (round-robin)]‧負載平衡模式, 需有 switch 設定 (trunk) 支援才能發揮實質效果
‧具容錯功能, 其中一張 Slave 網卡失效仍可持續運作

1     active-backup (Fault Tolerance)    ‧同一時間只有單一 Slave 網卡運作
‧Active Slave 網卡失效時自動啟用次一順位 Slave 網卡
‧不需 switch 支援

2     balance-xor
‧ 如2 個網卡綁定後,
3     broadcast     ‧所有 Slave 網卡一齊收送網路封包
‧具容錯功能, 其中一張 Slave 網卡失效仍可持續運作

4     802.3ad     Dynamic
. 在 TEAMING 的 NIC 裡,只走一個 NIC,當某一條線斷線,才走第二/第三/第四 的 TEAMING 備用線路。

5     balance-tlb     ‧傳出自動負載平衡
‧傳入由 Current Active Slave 負責
‧具容錯功能, 其中一張 Slave 網卡失效仍可持續運作
‧不需 switch 支援及設定

6     balance-alb (Adptive Loading balance)     ‧傳出及傳入皆自動負載平衡
‧具容錯功能, 其中一張 Slave 網卡失效仍可持續運作
‧Slave 網卡 driver 需支援 setting hardware address 功能
‧不需 switch 支援及設定
========================================================================
DEVICE=bond0
IPADDR=12.12.12.12
NETMASK=255.255.255.0
NETWORK=12.12.12.0B
ROADCAST=12.12.12.255
IPV6INIT=yes
IPV6ADDR=3ffe:ffff:0000:f101::10/64
IPV6ADDR_SECONDARIES=fec0:0:0:1::10/64
IPV6_MTU=1280
ONBOOT=yes
BOOTPROTO=none
USERCTL=no
#=========================

VN:F [1.9.4_1102]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.4_1102]
Rating: +1 (from 1 vote)

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>