配置Cisco交换机二层Etherchannel

交换机S1, S2之间有两条链路相连,如果捆绑在一起,成为一个逻辑聚合链路 (trunk),不但增加带宽,并提供冗余容错的能力。
外文名
EtherChannel
作 用
增加带宽,并提供冗余容错的能力
应 用
主干链路
特 点
提供冗余的、高速的连接方式

实验拓扑如下图
配置Cisco交换机二层Etherchannel

我们先把基本配置设置好,以及添加vlan 端口划分vlan,trunk口

很明显,sw1是根交换机,而且根据MAC,所以SW0的一个端口要阻塞掉。

etherchannel最多捆8条线路,并且捆绑的链路属性必须一致(带宽,工作模式是全双工还是半双工,端口模式也要一致,端口是F口还是G口也要一致,允许的vlan也要一致)

etherchannel捆绑链路可以增加带宽。

好了 继续开始试验部分

我们配置好了 基本部分, show spanner-tree一下

配置Cisco交换机二层Etherchannel
发现sw0上面的端口f0/2对于vlan2,3都是阻塞的

VLAN0001
Spanning tree enabled protocol ieee
Root ID Priority 32769
Address 0004.9A8D.1D3C
This bridge is the root
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec

Bridge ID Priority 32769 (priority 32768 sys-id-ext 1)
Address 0004.9A8D.1D3C
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 20

Interface Role Sts Cost Prio.Nbr Type


Fa0/1 Desg FWD 19 128.1 P2p 红色部分 就是PID(由两部分组成,128表示优先级,后面表示 端口号)
Fa0/2 Desg FWD 19 128.2 P2p

好了 开始捆绑链路
sw1(config-if-range)#channel-protocol ?
lacp Prepare interface for LACP protocol LACP是标准化协议
pagp Prepare interface for PAgP protocol PAGP是cisco私有协议

sw1(config-if-range)#channel-protocol pagp 协议捆绑好了,还要把它分到一个组里面去,下面继续
sw1(config-if-range)#channel-group 1 mode ? 1 表示组编号
active Enable LACP unconditionally active是属于LACP的模式,我们选用了PAGP的协议后,就无法使用该模式了 属于被动模式
auto Enable PAgP only if a PAgP device is detected auto是属于PAGP的模式,是被动模式
desirable Enable PAgP unconditionally desirable是属于PAGP的主动模式
on Enable Etherchannel only on与协议无关,不属于任何协议,但是它可以强制开启channel信道
passive Enable LACP only if a LACP device is detected passive 属于LACP的模式,属于主动模式

sw1(config-if-range)#channel-group 1 mode desirable 我们采取主动模式
sw1(config-if-range)#
Creating a port-channel interface Port-channel 1

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to down

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/2, changed state to down

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/2, changed state to up

sw1(config-if-range)#

另外一台交换机配置同样的命令,,但是要再次说明一下,因为sw1采取了主动模式,所以对端无论是主动还是被动模式,都无所谓,协议都可以成功。

sw0(config-if-range)#channel-protocol pagp
sw0(config-if-range)#channel-g
sw0(config-if-range)#channel-group 1m
sw0(config-if-range)#channel-group 1 m
sw0(config-if-range)#channel-group 1 mode d
sw0(config-if-range)#channel-group 1 mode desirable
sw0(config-if-range)#
Creating a port-channel interface Port-channel 1

这里有一个重点,
Creating a port-channel interface Port-channel 1 这里创建了一个虚拟端口,port-channel 1 这个端口,也就是说我们可以对这个端口进行配置,比如配置成trunk,access,如果是三层交换机,也可以配置IP地址。的
sw0(config)#interface port-channel 1
sw0(config-if)#

好了,这时候,我们就可以通过 show spanner-tree来查看一下

Interface Role Sts Cost Prio.Nbr Type


Po1 Root FWD 9 128.27 Shr 这里就可以看到po1端口了,看不到原来的f0/1-2了,因为已经把他们捆绑到一起了。

好了,现在我们看一下拓扑
配置Cisco交换机二层Etherchannel
两根线都亮起来了。

下面还有重点知识,就是etherchannel是基于什么负载方式呢?
默认的是基于源MAC负载,意思就是如果源MAC有一个,那么直走一条线路,如果,源MAC有两个,才会利用2条线路,有3个源MAC就利用三条线路。
sw0# show etherchannel load-balance 这条命令就可以看出默认的负载方式
EtherChannel Load-Balancing Operational State (src-mac):
Non-IP: Source MAC address
IPv4: Source MAC address 基于源MAC的负载
IPv6: Source MAC address

我们通过实验就可以看出,一个源MAC发送数据包的时候,只有一个线的灯是闪烁的。

负载方式可以手动修改
sw0(config)#port-channel load-balance ?
dst-ip Dst IP Addr 目的IP的负载
dst-mac Dst Mac Addr 目的MAC的负载
src-dst-ip Src XOR Dst IP Addr 源 目标 IP的负载
src-dst-mac Src XOR Dst Mac Addr 源 目标 MAC的 负载
src-ip Src IP Addr 源 IP的负载
src-mac Src Mac Addr 源MAC的负载

sw0#show etherchannel summary 查看etherchannel的组成和结果
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
------±------------±----------±---------------------------------------------

1 Po1(SU) PAgP Fa0/1§ Fa0/2§ SU中的S表示二层,U表示正在使用中,端口的P表示在以太信道中的,如果后面是D 的话,表示这个端口是宕掉的

如果想取消PAGP协议,直接no掉就可以,然后可以更换LACP协议 配置命令一样