lagg 支持 IEEE 802.3ad 鏈路聚合控制協(xié)議 (LACP) 和標記協(xié)議。 LACP 能夠在節(jié)點與若干鏈路聚合組之間協(xié)商鏈路。 每一個鏈路聚合組 (LAG) 由一組相同速度、以全雙工模式運行的網口組成。 流量在 LAG 中的網口之間, 會以總速度最大的原則進行分攤。當物理鏈路發(fā)生變化時, 鏈路聚合會迅速適應變動形成新的配置。
一、調入lagg內核模塊
方法1. 加入內核并重編和加載,我用此方法來實現
device lagg
方法2.以module調入(kldload), 注意調入前先確認lagg.ko模塊存在于/boot/kernel/
if_lagg_load="YES"
二、在rc.conf下配置lagg。
假設網卡標識為bge0和bge1
ifconfig_bge0="up"
ifconfig_bge1="up"
cloned_interfaces="lagg0"
ifconfig_lagg0="laggproto lacp laggport bge0 laggport bge1 192.168.10.21 netmask 255.255.255.0"
三、cisco 2950下配置channel-protocol和channel-group.
# show run 的有關channel-protocol的內容
interface FastEthernet0/23
channel-group 6 mode active
channel-protocol lacp
!
interface FastEthernet0/24
channel-group 6 mode active
channel-protocol lacp
!
具體配置:
# enable
# conf t
# int fa0/24
# channel-protocol lacp
# channel-group 6 mode active
# exit
# int fa0/23
# channel-protocol lacp
# channel-group 6 mode active
# exit
# exit
# write
四、重啟pc, 這樣就可以實現FreeBSD 的兩個網口作為一個負載均衡和故障轉移鏈路聚合組接到交換機上。
A. FreeBSD上的狀態(tài).
#ifconfig
root@s2[~]# ifconfig
bge0: flags=8843UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
options=9bRXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM>
ether 00:0f:20:32:5a:af
media: Ethernet autoselect (100baseTX full-duplex>)
status: active
lagg: laggdev lagg0
bge1: flags=8843UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
options=9bRXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM>
ether 00:0f:20:32:5a:af
media: Ethernet autoselect (100baseTX full-duplex>)
status: active
lagg: laggdev lagg0
lo0: flags=8049UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
inet 127.0.0.1 netmask 0xff000000
lagg0: flags=8843UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
options=9bRXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM>
ether 00:0f:20:32:5a:af
inet 192.168.10.21 netmask 0xffffff00 broadcast 192.168.10.255
media: Ethernet autoselect
status: active
laggproto lacp
laggport: bge1 flags=1cACTIVE,COLLECTING,DISTRIBUTING>
laggport: bge0 flags=1cACTIVE,COLLECTING,DISTRIBUTING>
B. 在交換機上的狀態(tài).
swicth#show lacp 6 neighbor
Flags: S - Device is requesting Slow LACPDUs
F - Device is requesting Fast LACPDUs
A - Device is in Active mode P - Device is in Passive mode
Channel group 6 neighbors
Partner's information:
LACP port Oper Port Port
Port Flags Priority Dev ID Age Key Number State
Fa0/23 SA 32768 000f.2032.5aaf 3s 0x86 0x1 0x3D
Fa0/24 SA 32768 000f.2032.5aaf 5s 0x86 0x2 0x3D
swicth#show lacp 6 counters
LACPDUs Marker Marker Response LACPDUs
Port Sent Recv Sent Recv Sent Recv Pkts Err
---------------------------------------------------------------------
Channel group: 6
Fa0/23 2816 2603 0 1 1 0 0 ## 這里可以看到流量是平均分擔的.
Fa0/24 2818 2605 0 3 3 0 0