实验拓朴:
实验说明:如以上拓朴,交换机SW1和SW2之间有两链干线链路,允许VLAN1和VLAN10的流量通过,本实实验将在这两条干线上实现STP的负载均衡。
=============================================
一、查看当前生成树
1、查看在VLAN1中的STP信息
switch1#sh spanning-tree vlan 1 //在交换机1上查看STP
VLAN1 is executing the ieee compatible Spanning Tree protocol
Bridge Identifier has priority 32768, address cc00.0138.0000 //SW1的BID
Configured hello time 2, max age 20, forward delay 15
We are the root of the spanning tree //可见SW1为VLAN1的根桥
……
Port 2 (FastEthernet0/1) of VLAN1 is forwarding
Port path cost 19, Port priority 128, Port Identifier 128.2.
Designated root has priority 32768, address cc00.0138.0000
Designated bridge has priority 32768, address cc00.0138.0000
Designated port id is 128.2, designated path cost 0
……
switch1#sh span vlan 1 brief
VLAN1
Spanning tree enabled protocol ieee
Root ID Priority 32768
……
Bridge ID Priority 32768
……
//如下所见根桥上所有端口为指定端口,处于转发状态。
Interface Designated
Name Port ID Prio Cost Sts Cost Bridge ID Port ID
-------------------- ------- ---- ----- --- ----- -------------------- -------
FastEthernet0/1 128.2 128 19 FWD 0 32768 cc00.0138.0000 128.2
FastEthernet0/2 128.3 128 19 FWD 0 32768 cc00.0138.0000 128.3
FastEthernet0/7 128.8 128 19 FWD 0 32768 cc00.0138.0000 128.8
----------------------------------------------------------------------------------------------
Switch2#sh spanning-tree vlan 1 //在交换机2上查看STP
VLAN1 is executing the ieee compatible Spanning Tree protocol
Bridge Identifier has priority 32768, address cc00.0ac8.0000 //本地BID
Configured hello time 2, max age 20, forward delay 15
Current root has priority 32768, address cc00.0138.0000 //根桥ID
Root port is 2 (FastEthernet0/1), cost of root path is 19
//根端口
Topology change flag not set, detected flag not set
……
Port 2 (FastEthernet0/1) of VLAN1 is forwarding //根端口处于转发
Port path cost 19, Port priority 128, Port Identifier 128.2.
……
Port 3 (FastEthernet0/2) of VLAN1 is blocking //非指定端口处于阻塞状态
Port path cost 19, Port priority 128, Port Identifier 128.3.
Designated root has priority 32768, address cc00.0138.0000
Designated bridge has priority 32768, address cc00.0138.0000 //指定网桥是SW1。
Designated port id is 128.3, designated path cost 0
……
Port 9 (FastEthernet0/8) of VLAN1 is forwarding
Port path cost 19, Port priority 128, Port Identifier 128.9.
Designated root has priority 32768, address cc00.0138.0000
Designated bridge has priority 32768, address cc00.0ac8.0000 //指定交换机为本地,该端口是一个指定端口
……
Switch2#sh span vlan 1 brief
……
Interface Designated
Name Port ID Prio Cost Sts Cost Bridge ID Port ID
-------------------- ------- ---- ----- --- ----- -------------------- -------
FastEthernet0/1 128.2 128 19 FWD 0 32768 cc00.0138.0000 128.2
FastEthernet0/2 128.3 128 19 BLK 0 32768 cc00.0138.0000 128.3 //本端口处于阻塞状态
FastEthernet0/8 128.9 128 19 FWD 19 32768 cc00.0ac8.0000 128.9
--------------------------------------------------------
2、查看在VLAN10中的STP信息
switch1#sh span vlan 10
VLAN10 is executing the ieee compatible Spanning Tree protocol
Bridge Identifier has priority 32768, address cc00.0138.0001
Configured hello time 2, max age 20, forward delay 15
We are the root of the spanning tree
Switch2#sh span vlan 10
VLAN10 is executing the ieee compatible Spanning Tree protocol
Bridge Identifier has priority 32768, address cc00.06a0.0001
Configured hello time 2, max age 20, forward delay 15
Current root has priority 32768, address cc00.0138.0001
Root port is 2 (FastEthernet0/1), cost of root path is 19
……
Port 1 (FastEthernet0/0) of VLAN10 is forwarding
……
Port 2 (FastEthernet0/1) of VLAN10 is forwarding
……
Port 3 (FastEthernet0/2) of VLAN10 is blocking //此端口阻塞
……
==============================================
二、配置生成树以实现两条干线的负载均衡
通过以上的调试分析,我们看到VLAN 1和VLAN 10各有一个生成树,但都选SW1作为根,二者的逻辑拓朴图是一样的。SW2的fa0/1都是根端口,fa0/2都阻塞。这样所有VLAN在交换机间传的流量都走的是上边这条链路,这样两条链路没有实现负载平衡。在下面的任务中,我们来作一些调节,使不同VLAN的逻辑拓朴可以不一样,以让链路作负载平衡。
---------------------------------------
Switch2(config)#span vlan 10 priority 0 //设置SW2在VLAN10中的优先级
Switch2#sh span vlan 10
VLAN10 is executing the ieee compatible Spanning Tree protocol
Bridge Identifier has priority 0, address cc00.06a0.0001
Configured hello time 2, max age 20, forward delay 15
We are the root of the spanning tree //VLAN10的根桥变为SW2了,各端口处于转发状态
Switch2#sh span vlan 10 blockedports
Name Blocked Interfaces List
-------------------- ------------------------------------
Number of blocked ports (segments) in VLAN10 : 0 //0个被阻塞
-------------------------------------------------------------------------------------------------
switch1#sh span vlan 10 blockedports //查看SW1的阻塞端口
Name Blocked Interfaces List
-------------------- ------------------------------------
VLAN10 Fa0/2
Number of blocked ports (segments) in VLAN10 : 1 //仍是fa0/2个被阻塞
switch1#sh span vlan 10 brief
……
Interface Designated
Name Port ID Prio Cost Sts Cost Bridge ID Port ID
-------------------- ------- ---- ----- --- ----- -------------------- -------
FastEthernet0/1 128.2 128 19 FWD 0 0 cc00.06a0.0001 128.2
FastEthernet0/2 128.3 128 19 BLK 0 0 cc00.06a0.0001 128.3
FastEthernet0/3 128.4 128 19 FWD 19 32768 cc00.0138.0001 128.4
FastEthernet0/7 128.8 128 19 FWD 19 32768 cc00.0138.0001 128.8
---------------------------------------------------------------------------------------------------------
从以上看,通过调整,根作为变化,但阻塞链路仍没有变,所以所有流量仍走上,没有起到负载,再调端口来测试。
---------------------------------------------------------------------
switch1#conf t
switch1(config)#int fa0/2
switch1(config-if)#span vlan 10 port-priority 100
//端口缺省缺省为128,此处阻塞端口的优先级修改为100
switch1(config-if)#do sh span vlan 10 block
% Ambiguous command: "do sh span vlan 10 block"
switch1(config-if)#do sh span vlan 10 blockedports
Name Blocked Interfaces List
-------------------- ------------------------------------
VLAN10 Fa0/2 //
阻塞端口没有变,调整端口优先级没有起作用
Number of blocked ports (segments) in VLAN10 : 1
switch1(config-if)#span vlan 10 cost 10
//降低端口开销
switch1(config-if)#
do sh span vlan 10 block
Name Blocked Interfaces List
-------------------- ------------------------------------
VLAN10 Fa0/1 //阻塞端口改变,修改生效
Number of blocked ports (segments) in VLAN10 : 1
------------------------------------------------------------------
通过以上配置,当在VLAN1中时,流量走上面一条链路。在VLAN10中,流量走下面一条链路。从而实现了负载均衡。