3.4.1EtherChannel及其作用

交换机允许将多个端口聚合成一个逻辑端口或者称为EtherChannel。

通过端口聚合,可大大提高端口间链路的通信速度。比如,当用2个100Mbit/s的端口进行聚合时,所形成的逻辑端口的通信速度为200Mbit/s;若用4个,则为400Mbit/s。当EtherChannel内的某条链路出现故障时,该链路的流量将自动转移到其余链路上,自动提供冗余和负载均衡。

PAgP是Cisco专有的端口聚合协议,LACP(Link Aggregation Control Protocol,链路聚合控制协议)则是一种标准的协议。 

3.4.2 EtherChannel配置

 参与聚合的端口必须具备相同的属性,如相同的速度、单双工模式、trunk模式、trunk封装方式和VLAN等。端口配置模式下使用命令:

channel-group number mode [active|auto|desirable |on|passive]

进行配置。

参数说明:

 active     只使用LACP协议(Enable LACP unconditionally)

  auto      使用PAgP仅当对端设备使用PagP时( Enable PAgP only if a PAgP device is detected)

  desirable  只使用PAgP(Enable PAgP unconditionally)

  on       只进行端口聚合,默认使用PAgP(Enable Etherchannel only)

  passive   使用LACP仅当对端设备使用LACP 时(Enable LACP only if a LACP device is detected)

两端设备对应端口聚合应该使用同样的协议,否则至少有一端的聚合不会成功。

1.配置实例

 比如在如图所示的网络中,两核心交换机之间的链路采用两个端口的EtherChannel。


 

配置步骤:

Sw0(config)#interface range G0/1-2          //配置G0/1和G0/2口

Sw0 (config-if)#channel-group 10 mode on   //可理解为把G0/1-2加入10号逻辑端口组(通道组)

Sw0(config-if)#exit

 

 

Sw1(config)#interface range G0/1-2

Sw1(config-if)#channel-group 10 mode on

Sw1(config-if)#exit

2. 查看配置:

SW1#show etherchannel summary 

Flags:  D - down        P - in port-channel

        I - stand-alone s - suspended

        H - Hot-standby (LACP only)

        R - Layer3      S - Layer2

        U - in use      f - failed to allocate aggregator

        u - unsuitable for bundling

        w - waiting to be aggregated

        d - default port

Number of channel-groups in use: 1

Number of aggregators:         1

 

Group  Port-channel  Protocol    Ports

------+-------------+-----------+----------------------------------------------

10     Po10(SU)      PAgP     Gig0/1(P)Gig0/2(P) 

 

显示这两个接口已经捆绑成为一个通道组接口Port-channel 10,Po10(SU)中的“S”说明这个通道组接口工作在第二层,U表示已在使用,使用的协议为PAgP,通道组聚合了两个接口Gig0/1和Gig0/2。

Cisco 3560交换机支持48个EtherChannel 配置,每组最多支持8个端口聚合。

3.负载均衡配置

EtherChannel可以自动执行负载均衡,当EtherChannel执行负载均衡时,按照默认策略进行。

可以根据不同条件来决定和配置负载均衡策略。如MAC地址、IP地址等都可以作为负载均衡策略的参数。但是不是每种交换机都能支持所有这些参数,越高端的交换机支持的参数就越多。

例如,Cisco 3560的负载均衡配置

Switch(config)#port-channel load-balance ?

  dst-ip       Dst IP Addr

  dst-mac      Dst Mac Addr

  src-dst-ip   Src XOR Dst IP Addr

  src-dst-mac  Src XOR Dst Mac Addr

  src-ip       Src IP Addr

  src-mac      Src Mac Addr

支持多种策略

 

===============================

 

**************** 链路聚合 ****************
SW1:2960
interface Port-channel 1
description Channel group member f0/1-2
switchport
switchport trunk encapsulation dot1q
switchport mode trunk

int ran f0/1 - 2
description Connect to SW5 on port f0/1-2
switchport trunk encapsulation dot1q
switchport mode trunk
channel-group 1 mode desirable
switchport trunk allowed vlan all

SW2:2960
interface Port-channel 2
description Channel group member f0/1-2
switchport
switchport trunk encapsulation dot1q
switchport mode trunk

int ran f0/1 - 2
description Connect to SW5 on port f0/3-4
switchport trunk encapsulation dot1q
switchport mode trunk
channel-group 2 mode desirable
switchport trunk allowed vlan all

SW3:2960
interface Port-channel 3
description Channel group member f0/1-2
switchport
switchport trunk encapsulation dot1q
switchport mode trunk

int ran f0/1 - 2
description Connect to SW5 on port f0/5-6
switchport trunk encapsulation dot1q
switchport mode trunk
channel-group 3 mode desirable
switchport trunk allowed vlan all

SW4:2960
interface Port-channel 4
description Channel group member f0/1-2
switchport
switchport trunk encapsulation dot1q
switchport mode trunk

int ran f0/1 - 2
description Connect to SW5 on port f0/7-8
switchport trunk encapsulation dot1q
switchport mode trunk
channel-group 4 mode desirable
switchport trunk allowed vlan all


SW5: 3560
interface Port-channel 1
description Channel group member SW1 f0/1-2
switchport
switchport trunk encapsulation dot1q
switchport mode trunk

int ran f0/1 - 2
description Connect to SW1 on port f0/1-2
switchport trunk encapsulation dot1q
switchport mode trunk
channel-group 1 mode auto
switchport trunk allowed vlan all

interface Port-channel 2
description Channel group member SW2 f0/1-2
switchport
switchport trunk encapsulation dot1q
switchport mode trunk

int ran f0/3 - 4
description Connect to SW2 on port f0/1-2
switchport trunk encapsulation dot1q
switchport mode trunk
channel-group 2 mode auto
switchport trunk allowed vlan all

interface Port-channel 3
description Channel group member SW3 f0/1-2
switchport
switchport trunk encapsulation dot1q
switchport mode trunk

int ran f0/5 - 6
description Connect to SW3 on port f0/1-2
switchport trunk encapsulation dot1q
switchport mode trunk
channel-group 3 mode auto
switchport trunk allowed vlan all

interface Port-channel 4
description Channel group member SW4 f0/1-2
switchport
switchport trunk encapsulation dot1q
switchport mode trunk

int ran f0/7 - 8
description Connect to SW4 on port f0/1-2
switchport trunk encapsulation dot1q
switchport mode trunk
channel-group 4 mode auto
switchport trunk allowed vlan all


sh ip int bri