一、链路聚合简介1.链路聚合原理将两个或更多数据信道结合成一个单个的信道,该信道以一个单个的更高带宽的逻辑链路出现。
链路聚合一般用来连接一个或多个带宽需求大的设备2.作用将多个物理以太网端口聚合在一起形成一个逻辑上的聚合组,使用链路聚合服务的上层实体把同一聚合组内的多条物理链路视为一条逻辑链路CP协议Link Aggregation Control Protocol 链路聚合控制协议LACP 协议通过LACPDU(Link Aggregation Control Protocol Data Unit,链路聚合控制协议数据单元)与对端交互信息。
使能某端口的LACP 协议后,该端口将通过发送LACPDU 向对端通告自己的系统LACP 协议优先级、系统MAC、端口的LACP 协议优先级、端口号和操作Key。
对端接收到LACPDU 后,将其中的信息与其它端口所收到的信息进行比较,以选择能够处于Selected 状态的端口,从而双方可以对端口处于Selected 状态达成一致。
操作Key 是在链路聚合时,聚合控制根据端口的配置(即速率、双工模式、up/down 状态、基本配置等信息)自动生成的一个配置组合。
在聚合组中,处于Selected 状态的端口有相同的操作Key。
4.链路聚合的端口的注意事项1 端口均为全双工模式;2 端口速率相同;3 端口的类型必须一样,比如同为以太口或同为光纤口;4 端口同为access端口并且属于同一个vlan或同为trunk端口;5 如果端口为trunk端口,则其allowed vlan和nativevlan属性也应该相同。
5.链路聚合配置命令1)CISCOa)把指定端口给聚合组,并指定聚合方式SW(config)interface Ethernet0/1SW(config-ethernet0/1)#port-group 1 mode(active|passive|on)b)进入聚合端口的配置模式SW(config)#interface port-channel 1进入该模式可以配置一些端口参数c)名词解释Port-channel 组号:范围是1-16聚合模式active(0)启动端口的LACP 协议,并设置为Active 模式;passive(1)启动端口的LACP 协议,并且设置为Passive 模式;on(2)强制端口加入Port Channel,不启动LACP 协议。
2)H3C手工聚合方式a)创建手工聚合组1link-aggregation group 1 mode manualb)将端口加入聚合组interface ethernet0/1port link-aggregation group 1采用静态LACP聚合方式a)设置系统的LACP协议优先级(可选)Lacp system-priority system-priority // 缺省情况下是32768b)创建静态LACP聚合组link-aggregation group 1 mode staticc)将端口加入聚合组interface ethernet0/1port link-aggregation group 1d)配置端口LACP的优先级(可选)Lacp port-priority port-priority// 缺省情况下是327686.负载均衡1)作用自适应负载平衡Fast EtherChannel处理多个链路间的通信量负载平衡任务。
负载平衡在冗余并行路径间平均分配通信量。
如果任何一个链路失效,其他的链路将自动接管这个负载份额而不会中断。
2)配置命令CISCOSW [config]#port-channel load-balance method——源地址src-ip——目的地址dst-ip——源和目的src-dst-ip——源mac地址src-mac——目的mac地址dst-mac——源和目的mac src-dst-mac——源端口号src-port——目的端口号dst-port——源和目的端口号src-dst-portH3Clink-aggregation load-sharing mode { { destination-ip | destination-port | ip-protocol | source-ip | source-port }二、实验Cisco私有的PAgP的链路聚合协议配置(PT模拟2层)1.实验拓扑说明:默认情况下,交换机会使用STP协议阻塞其中某个端口,因为上面的网络存在环路。
使用PAgP链路聚合充分利用冗余的链路带宽2.配置Switch>enSwitch#conf tSwitch(config)#hostname SW0SW0(config)#int ra fa 0/1-2SW0(config-if-range)#no shSW0(config-if-range)#switchportSW0(config-if-range)#channel-protocol ?lacp Prepare interface for LACP protocolpagp Prepare interface for PAgP protocolSW0(config-if-range)#channel-protocol pagpSW0(config-if-range)#channel-group ?<1-48> Channel group numberSW0(config-if-range)#channel-group 1 mode ?active Enable LACP unconditionallyauto Enable PAgP only if a PAgP device is detecteddesirable Enable PAgP unconditionallyon Enable Etherchannel onlypassive Enable LACP only if a LACP device is detectedSW0(config-if-range)#channel-group 1 mode desirable //主动进入协商状态Switch>enSwitch#conf tSwitch(config)#hostname SW1SW1(config)#int ra fa 0/1-2SW1 (config-if-range)#no shSW1 (config-if-range)#switchportSW1 (config-if-range)#channel-protocol pagpSW1 (config-if-range)#channel-group 1 mode auto //被动进入协商模式Switch(config-if-range)#%LINK-5-CHANGED: Interface Port-channel 1, changed state to up%LINEPROTO-5-UPDOWN: Line protocol on Interface Port-channel 1, changed state to upSwitch(config-if-range)#3.验证查看聚合组信息SW0(config-if-range)#do show etherchannel port-channelChannel-group listing:----------------------Group: 1----------Port-channels in the group:---------------------------Port-channel: Po1------------Age of the Port-channel = 00d:00h:01m:56sLogical slot/port = 2/1 Number of ports = 2GC = 0x00000000 HotStandBy port = null Port state = Port-channelProtocol = PAGPPort Security = DisabledPorts in the Port-channel:Index Load Port EC state No of bits------+------+------+------------------+-----------0 00 Fa0/1 Desirable-Sl 00 00 Fa0/2 Desirable-Sl 0Time since last port bundled: 00d:00h:01m:05s Fa0/2SW0(config-if-range)#查看聚合链路的汇总信息SW0(config-if-range)#do show etherchannel summaryFlags: D - down P - in port-channelI - stand-alone s - suspendedH - Hot-standby (LACP only)R - Layer3 S - Layer2 //二层U - in use f - failed to allocate aggregatoru - unsuitable for bundlingw - waiting to be aggregatedd - default portNumber of channel-groups in use: 1Number of aggregators: 1Group Port-channel Protocol Ports------+-------------+-----------+----------------------------------------------1 Po1(SU) PAgP Fa0/1(P) Fa0/2(P)SW0(config-if-range)#4.测试容错性配置SW0和SW1的VLAN 1 的IP地址,测试聚合链路的容错SW0(config-if-range)#int vlan 1SW0(config-if)#no shutdownSW0(config-if)#ip add 192.168.1.1 255.255.255.0SW0(config-if)#SW1(config-if-range)#int vlan 1SW1(config-if)#no shSW1(config-if)#ip add 192.168.1.2 255.255.255.0SW1(config-if)#测试聚合端口的冗余容错特性在SW0上向SW1持续发送ICMP数据包SW0(config-if)#do pingProtocol [ip]: ipTarget IP address: 192.168.1.2Repeat count [5]: 10000Datagram size [100]: 100Timeout in seconds [2]: 2Extended commands [n]: nSweep range of sizes [n]: nType escape sequence to abort.Sending 10000, 100-byte ICMP Echos to 192.168.1.2, timeout is 2 seconds:!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!然后在SW1上将聚合组中的fa 0/2关掉,观察ping数据包是否中断SW1(config)#int fa 0/2SW1(config-if)#no shSW1(config-if)#no shutdownSW1(config-if)#shSW1(config-if)#shutdown%LINK-5-CHANGED: Interface FastEthernet0/2, changed state to administratively down%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/2, changed state todownSW1(config-if)#!!!!!!!!!!!!!%LINK-5-CHANGED: Interface FastEthernet0/2, changed state to down%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/2, changed state to down.........Success rate is 92 percent (122/132), round-trip min/avg/max = 15/30/32 msSW0(config-if)#这个是PT模拟器的一个局限性,如果在真机上实验,两台设备之间的连通性是不会中断的。