假設在當前網絡拓撲中的每條鏈路的帶寬是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:表示所使用的協議標準是思科私有的。