假设在当前网络拓扑中的每条链路的带宽是100M,SW3作为一个接入层交换机,如果我们在接入层交换机中接入了两台PC,每台PC是100M的数据流量,那么两台PC加起来就是200M的流量。相当于接入层交换机一下子接入了200M的流量,而SW3交换机的链路只能处理100M流量,这样会给当前网络带来极大的负担,但是通过Etherchannel技术将两条以上的物理链路逻辑上合并成一条链路,就可以处理更多的数据流量。
如上图所示,SW1和SW2交换机之间有两条100M的物理链路,通过通过Etherchannel技术可以将这两条物理链路从逻辑上合并成一条以太链路,然后这条“逻辑链路”就可以处理200M的数据流量了。
开启SW1设备的Trunk模式:
SW1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
SW1(config)#int range f0/0 , f0/1
SW1(config-if-range)#switchport trunk encapsulation dot1q
SW1(config-if-range)#switchport mode trunk
然后将SW1设备的f0/0接口和f0/1接口加入到channel-group 1里面,配置如下:
SW1(config-if-range)#channel-group 1 mode on
Creating a port-channel interface Port-channel1
SW1(config-if-range)#
*Mar 1 00:06:54.099: %EC-5-BUNDLE: Interface Fa0/0 joined port-channel Po1
*Mar 1 00:06:54.135: %EC-5-BUNDLE: Interface Fa0/1 joined port-channel Po1
*Mar 1 00:06:56.015: %LINK-3-UPDOWN: Interface Port-channel1, changed state to up
*Mar 1 00:06:57.015: %LINEPROTO-5-UPDOWN: Line protocol on Interface Port-channel1, changed state to up
SW1(config-if-range)#
从上面给出的信息可以看出SW1设备的两条链路都加入到组1了。
开启SW2设备的Trunk模式,并把f0/0接口和f0/1接口加入到channel-group 1,配置如下:
SW2(config-if-range)#channel-group 1 mode on
Creating a port-channel interface Port-channel1
SW2(config-if-range)#
*Mar 1 00:09:32.695: %EC-5-BUNDLE: Interface Fa0/0 joined port-channel Po1
*Mar 1 00:09:32.735: %EC-5-BUNDLE: Interface Fa0/1 joined port-channel Po1
*Mar 1 00:09:34.563: %LINK-3-UPDOWN: Interface Port-channel1, changed state to up
*Mar 1 00:09:35.563: %LINEPROTO-5-UPDOWN: Line protocol on Interface Port-channel1, changed state to up
SW2(config-if-range)#
部署了Etherchannel技术后,查看物理以太链路的信息:
SW2#show etherchannel summary
Flags: D - down P - in port-channel
I - stand-alone s - suspended
R - Layer3 S - Layer2
U - in use
Group Port-channel Ports
-----+------------+-----------------------------------------------------------
1 Po1(SU) Fa0/0(P) Fa0/1(P)
SW2#
Po1(SU)里的S表示所在层,当前是处于二层,U表示正在使用,SU合起来表示二层正在使用Etherchannel,从以上该出的信息可以看出以太网通道建立成功,这样SW1和SW2逻辑上合并成一条链路了。
show命令查看SW2设备的链路信息:
SW2#show interfaces port-channel 1
Port-channel1 is up, line protocol is up
Hardware is EtherChannel, address is cc02.0178.f000 (bia cc02.0178.f000)
//说明以太链路的带宽已经是200M了
MTU 1500 bytes, BW 200000 Kbit, DLY 1000 usec,
reliability 255/255, txload 1/255, rxload 1/255
Encapsulation ARPA, loopback not set
Keepalive set (10 sec)
Full-duplex, 100Mb/s
Members in this channel: Fa0/0 Fa0/1
ARP type: ARPA, ARP Timeout 04:00:00
Last input 00:00:01, output never, output hang never
Last clearing of "show interface" counters never
Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0
Queueing strategy: fifo
Output queue: 0/40 (size/max)
5 minute input rate 0 bits/sec, 0 packets/sec
5 minute output rate 0 bits/sec, 0 packets/sec
0 packets input, 0 bytes, 0 no buffer
Received 0 broadcasts, 0 runts, 0 giants, 0 throttles
0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored
0 input packets with dribble condition detected
0 packets output, 0 bytes, 0 underruns
0 output errors, 0 collisions, 1 interface resets
0 babbles, 0 late collision, 0 deferred
0 lost carrier, 0 no carrier
0 output buffer failures, 0 output buffers swapped out
SW2#
SW2#
可以看到以太通道的带宽为 200M。
然后通过show命令查看交换机设备的接口:
SW1#show ip int brief
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 unassigned YES unset up up
FastEthernet0/1 unassigned YES unset up up
FastEthernet0/2 unassigned YES unset up down
FastEthernet0/3 unassigned YES unset up down
FastEthernet0/4 unassigned YES unset up down
FastEthernet0/5 unassigned YES unset up down
FastEthernet0/6 unassigned YES unset up down
FastEthernet0/7 unassigned YES unset up down
FastEthernet0/8 unassigned YES unset up down
FastEthernet0/9 unassigned YES unset up down
FastEthernet0/10 unassigned YES unset up down
FastEthernet0/11 unassigned YES unset up down
FastEthernet0/12 unassigned YES unset up down
FastEthernet0/13 unassigned YES unset up down
FastEthernet0/14 unassigned YES unset up down
FastEthernet0/15 unassigned YES unset up down
//以太通道
Port-channel1 unassigned YES unset up up
Vlan1 unassigned YES unset up up
SW1#
从上面的接口中可以看到SW1交换机多了一个Port-channel1接口。
查看SW2的Trunk信息:
SW1#show interfaces trunk
Port Mode Encapsulation Status Native vlan
Po1 on 802.1q trunking 1
Port Vlans allowed on trunk
Po1 1-1005
Port Vlans allowed and active in management domain
Po1 1
Port Vlans in spanning tree forwarding state and not pruned
Po1 1
SW1#
Po1接口其实就是f0/0口和f0/1口合并后的接口。
关于Etherchannel技术的动态协商主要有以下两种标准:
- PAGP,是思科私有的一种标准
- LACP,是现在行业都在使用的一种标准
PAGP标准(思科私有):
SW1(config)#int range f0/1 , f0/4
SW1(config-if-range)#switchport trunk encapsulation dot1q
SW1(config-if-range)#switchport mode trunk
SW1(config-if-range)#channel-protocol pagp
SW1(config-if-range)#channel-group 1 mode desirable/auto
Desirable表示主动协商,Auto被动协商。
LACP标准(行业标准):
SW1(config)#int range f0/1 , f0/4
SW1(config-if-range)#switchport trunk encapsulation dot1q
SW1(config-if-range)#switchport mode trunk
SW1(config-if-range)#channel-protocol lacp
SW1(config-if-range)#channel-group 1 mode active/passive
主要关注最后一条命令,对于LACP标准来说,active表示主动协商,passive被动协商。
以PAGP标准(思科私有)为例,配置动态协商,下面的实验是基于思科的模拟器来完成的。
SW0交换机配置如下:
SW0(config)#int range f0/1 , f0/2
SW0(config-if-range)#switchport mode trunk
SW0(config-if-range)#channel-protocol pagp
SW0(config-if-range)#channel-group 1 mode desirable
这里SW0交换机配置为主动协商,那么对应的另一边就需要配置为被动协商模式。
SW1交换机配置如下:
SW1(config)#int range f0/1 , f0/2
SW1(config-if-range)#switchport mode trunk
SW1(config-if-range)#channel-protocol pagp
SW1(config-if-range)#channel-group 1 mode auto
设置SW1交换机被动协商。
查看SW0设备的以太通道状态:
SW0#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
------+-------------+-----------+----------------------------------------------
1 Po1(SU) PAgP Fa0/1(P) Fa0/2(P)
SW0#
PAgP:表示所使用的协议标准是思科私有的。