配置lagg, 实现cisco 2950 与Freebsd 7.0链路聚合笔记
lagg 支持 ieee 802.3ad 链路聚合控制协议 (lacp) 和标记协议。 lacp 能够在节点与若干链路聚合组之间协商链路。 每一个链路聚合组 (lag) 由一组相同速度、以全双工模式运行的网口组成。 流量在 lag 中的网口之间, 会以总速度最大的原则进行分摊。当物理链路发生变化时, 链路聚合会迅速适应变动形成新的配置。
一、调入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上的状态.
#ifconfig
root@s2[~]# ifconfig
bge0: flags=8843<up,broadcast,running,simplex,multicast> metric 0 mtu 1500
options=9b<rxcsum,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=8843<up,broadcast,running,simplex,multicast> metric 0 mtu 1500
options=9b<rxcsum,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=8049<up,loopback,running,multicast> metric 0 mtu 16384
inet 127.0.0.1 netmask 0xff000000
lagg0: flags=8843<up,broadcast,running,simplex,multicast> metric 0 mtu 1500
options=9b<rxcsum,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=1c<active,collecting,distributing>
laggport: bge0 flags=1c<active,collecting,distributing>
b. 在交换机上的状态.
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