1 頁 (共 1 頁)

NIC Teaming

發表於 : 2012-07-10 09:13:21
schumi
http://www.cyberciti.biz/tips/linux-bon ... rface.html

Step #1: Create a Bond0 Configuration File

Red Hat Enterprise Linux (and its clone such as CentOS) stores network configuration in /etc/sysconfig/network-scripts/ directory. First, you need to create a bond0 config file as follows:

代碼: 選擇全部

# vi /etc/sysconfig/network-scripts/ifcfg-bond0
Append the following linest:

代碼: 選擇全部

DEVICE=bond0
IPADDR=192.168.1.20
NETWORK=192.168.1.0
NETMASK=255.255.255.0
GATEWAY=192.168.1.254
USERCTL=no
BOOTPROTO=none
ONBOOT=yes
 
You need to replace IP address with your actual setup. Save and close the file.

Step #2: Modify eth0 and eth1 config files

Open both configuration using a text editor such as vi/vim, and make sure file read as follows for eth0 interface

代碼: 選擇全部

# vi /etc/sysconfig/network-scripts/ifcfg-eth0
Modify/append directive as follows:

代碼: 選擇全部

DEVICE=eth0
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none
HWADDR=xx:xx:xx:xx:xx:C1
Open eth1 configuration file using vi text editor, enter:

代碼: 選擇全部

# vi /etc/sysconfig/network-scripts/ifcfg-eth1
Make sure file read as follows for eth1 interface:

代碼: 選擇全部

DEVICE=eth1
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none
HWADDR=xx:xx:xx:xx:xx:C2
Save and close the file.

Step # 3: Load bond driver/module

Make sure bonding module is loaded when the channel-bonding interface (bond0) is brought up. You need to modify kernel modules configuration file:

代碼: 選擇全部

# vi /etc/modprobe.d/bonding.conf
Append following two lines:

代碼: 選擇全部

alias bond0 bonding
options bond0 mode=balance-alb miimon=100
Save file and exit to shell prompt. You can learn more about all bounding options by clicking here).

Step # 4: Test configuration

First, load the bonding module, enter:

代碼: 選擇全部

# modprobe bonding
Restart the networking service in order to bring up bond0 interface, enter:

代碼: 選擇全部

# service network restart
Make sure everything is working. Type the following cat command to query the current status of Linux kernel bounding driver, enter:

代碼: 選擇全部

# cat /proc/net/bonding/bond0
Sample outputs:

代碼: 選擇全部

Bonding Mode: load balancing (round-robin)
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 200
Down Delay (ms): 200
Slave Interface: eth0
MII Status: up
Link Failure Count: 0
Permanent HW addr: xx:xx:xx:xx:xx:C1
Slave Interface: eth1
MII Status: up
Link Failure Count: 0
Permanent HW addr: xx:xx:xx:xx:xx:C2
To kist all network interfaces, enter:

代碼: 選擇全部

# ifconfig
Sample outputs:

代碼: 選擇全部

bond0     Link encap:Ethernet  HWaddr xx:xx:xx:xx:xx:C1
 inet addr:192.168.1.20  Bcast:192.168.1.255  Mask:255.255.255.0
 inet6 addr: fe80::200:ff:fe00:0/64 Scope:Link
 UP BROADCAST RUNNING MASTER MULTICAST  MTU:1500  Metric:1
 RX packets:2804 errors:0 dropped:0 overruns:0 frame:0
 TX packets:1879 errors:0 dropped:0 overruns:0 carrier:0
 collisions:0 txqueuelen:0
 RX bytes:250825 (244.9 KiB)  TX bytes:244683 (238.9 KiB)
eth0      Link encap:Ethernet  HWaddr xx:xx:xx:xx:xx:C1
 UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1
 RX packets:2809 errors:0 dropped:0 overruns:0 frame:0
 TX packets:1390 errors:0 dropped:0 overruns:0 carrier:0
 collisions:0 txqueuelen:1000
 RX bytes:251161 (245.2 KiB)  TX bytes:180289 (176.0 KiB)
 Interrupt:11 Base address:0x1400
eth1      Link encap:Ethernet  HWaddr xx:xx:xx:xx:xx:C2
 UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1
 RX packets:4 errors:0 dropped:0 overruns:0 frame:0
 TX packets:502 errors:0 dropped:0 overruns:0 carrier:0
 collisions:0 txqueuelen:1000
 RX bytes:258 (258.0 b)  TX bytes:66516 (64.9 KiB)
 Interrupt:10 Base address:0x1480

Re: NIC Teaming

發表於 : 2012-07-10 15:34:38
schumi
http://www.coolaler.com/archive/index.php/t-113412.html

以下大部分引述網友的心得,加上自己實作過程)
前言:

為什麼需要將多片網卡虛擬成一片?

有時我們使用samba進行區域網路傳檔的時候,透過XP的"工作管理員",可以看到網路效能曲線圖會不穩定,時快時慢,甚至偶而還會停止。

這是因為samba主機的網路卡負載太重,若可以增加網路卡來分散負載,即可改善這個情況。


OS:Cent OS 4.1
bonding:
將多片網卡虛擬成一片(竄改成同一個IP/MAC),以便達到分散負載。虛擬後所有eth(#)網卡的IP和MAC將會變成完全相同,然後多出一個bond0的虛擬網卡。

這個功能本來是高階網路卡,如Intel、3COM之類才有的硬體功能,有自己的商業名詞,現在在Linux下也能夠用軟體實現,Linux下則是稱作bonding。

bonding 需要核心支援才能使用,因為Fedora的核心,已內建bonding 功能,所以不需要重新編譯核心。

硬體需求:同樣晶片的網路卡至少兩張以上。

例如:市面上常見的 RTL8139D 網路卡(螃蟹卡),一片才1百多元,只要使用bonding,就可以媲美高階網路卡的功能。

======================================================================
假設虛擬網卡(bond0)的IP:192.168.0.1
網段:192.168.0.0 / 255.255.255.0
廣播位址:192.168.0.255


/etc/modprobe.conf (在最後面加入兩行)
---------------------------------
alias bond0 bonding
options bond0 miimon=100 mode=6


/etc/sysconfig/network-scripts/ifcfg-bond0 (建立這個檔)
---------------------------------------------------------
DEVICE=bond0
USERCTL=no
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.0.1
NETMASK=255.255.255.0
NETWORK=192.168.0.0
BROADCAST=192.168.0.255

/etc/sysconfig/network-scripts/ifcfg-eth0 (修改內容如下)
---------------------------------------------------------
DEVICE=eth0
USERCTL=no
ONBOOT=yes
BOOTPROTO=none
MASTER=bond0
SLAVE=yes
HWADDR=00:20:ED:7C:27:XX

/etc/sysconfig/network-scripts/ifcfg-eth1 (修改內容如下)
----------------------------------------------------------
DEVICE=eth1
USERCTL=no
ONBOOT=yes
BOOTPROTO=none
MASTER=bond0
SLAVE=yes
HWADDR=00:20:ED:7D:27:XX
#(這可設也可以不設,如果有好幾張依樣型號的網卡,設定MAC就可以直接指定哪一張網卡要mapping到eth幾了,至於每張網卡的MAC請用直接看卡上有標:p)


設定完成後,Reboot,或是service network restart,都可以 !
======================================================================
說明:
-------------------------------------
miimon=100

miimon 是指多久時間要檢查網路一次,單位是ms(毫秒)

這邊的100,是100ms,即是0.1秒
意思是假設其中有一條網路斷線,會在0.1秒內自動備援

mode 共有七種(0~6)
mode=0:平衡負載模式,有自動備援,但需要"Switch"支援及設定。
mode=1:自動備援模式,其中一條線若斷線,其他線路將會自動備援。
mode=6:平衡負載模式,有自動備援,不需要"Switch"支援及設定。
也就是一般的Switching Hub就可以了!
詳細資訊可以參考/usr/src/linux/Documentation/networking/bonding.txt