辍耕录 2017-12-09
实验12: STP
Ø 实验目的
通过本实验,读者可以掌握如下技能:
(1) 理解STP 的工作原理
(2) 掌握STP 树的控制
(3) 利用PVST 进行负载平衡
Ø 实验拓扑
SW1 和SW2 模拟为核心层的交换机,而S3 为接入的交换机. SW1 和SW2 实际上是三层交换机,我们这里并不利用其三层功能,所以它们也采用二层交换机的图标
Ø 实验步骤
在网络中配置2 个VLAN,不同VLAN 的STP 具有不同的根桥,实现负载平衡。
n 步骤1:利用VTP 在交换机上创建VLAN2,SW1 和SW2 之间的链路配置Trunk
SW1(vlan)#vtp domain vtp-test
SW1(vlan)#vlan 2 name vlan2
SW1(vlan)#vlan 3 name vlan3
SW1(config)#int f0/8
SW1(config-if)#sw trunk encap dot1q
SW1(config-if)#sw mode trunk
SW1(config)#int f0/11
SW1(config-if)#switchport trunk encapsulation dot1q
SW1(config-if)#switchport mode trunk
SW2(vlan)#vtp domain vtp-test
SW2(config)#int f0/8
SW2(config-if)#sw trunk encap dot1q
SW2(config-if)#sw mode trunk
SW2(config)#int f0/5
SW2(config-if)#sw trunk encap dot1q
SW2(config-if)#sw mode trunk
SW3(config)#vtp domain vtp-test
SW3(config)#int f0/11
SW3(config-if)#sw trunk encap dot1q
SW3(config-if)#sw mode trunk
SW3(config)#int f0/5
SW3(config-if)#sw mode trunk
SW3(config-if)#sw trunk encap dot1q
//请确认三条链路的Trunk 是否成功.在SW1 上配置VTP 的域名,并创建VLAN2,VLAN3.由于默认时SW2 和SW3 的VTP域名为空,它们将自动学习到SW1 的VTP 域名,同时SW2、SW3 也将自动学习到VLAN 2,VLAN3请确认是否成功。
n 步骤2:检查初始的STP 树
u SW1#show spanning-tree
VLAN0001
Spanning tree enabled protocol ieee
//以上表明运行的STP 协议是IEEE 的802.1D
Root ID Priority 32769
Address 000a.8a4b.6900
Cost 19
Port 8 (FastEthernet0/8)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
//以上显示VLAN 1 的STP 树的根桥信息,通过根桥的MAC 地址可以确定SW2是根桥
Bridge ID Priority 32769 (priority 32768 sys-id-ext 1)
Address 000a.8a52.b580
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300
//以上显示该交换机的桥ID
Interface Role Sts Cost Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Fa0/8 Root FWD 19 128.8 P2p
Fa0/11 Desg FWD 19 128.11 P2p
//以上显示该交换机各个接口的状态,f0/8和f0/11处于转发状态
VLAN0002
Spanning tree enabled protocol ieee
Root ID Priority 32770
Address 000a.8a4b.6900
Cost 19
Port 8 (FastEthernet0/8)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
//VLAN2的根桥也是SW2
Bridge ID Priority 32770 (priority 32768 sys-id-ext 2)
Address 000a.8a52.b580
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300
Interface Role Sts Cost Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Fa0/8 Root FWD 19 128.8 P2p
Fa0/11 Desg FWD 19 128.11 P2p
//以上是VLAN 2 的STP 树情况,VLAN 3 的STP 树和VLAN 1 的类似。默认时,Cisco 交换机会为每个VLAN 都生成一个单独的STP 树,称为PVST(Per VLAN Spanning Tree)。
u SW3#show spanning-tree
VLAN0001
Spanning tree enabled protocol ieee
Root ID Priority 32769
Address 000a.8a4b.6900
Cost 19
Port 5 (FastEthernet0/5)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32769 (priority 32768 sys-id-ext 1)
Address 000c.cea2.8e00
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300
Interface Role Sts Cost Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Fa0/5 Root FWD 19 128.5 P2p
Fa0/11 Altn BLK 19 128.11 P2p
//对于VLAN 1 来说,f0/5是根端口,处于转发状态, f0/11是阻塞口
n 步骤3:控制S1 为VLAN1 的根桥,S2 为VLAN2 的根桥
SW1(config)#spanning-tree vlan 2 priority 4096
或 SW1(config)#spanning-tree vlan 2 root primary
SW1#show spanning-tree
VLAN0001
Spanning tree enabled protocol ieee
Root ID Priority 4097
Address 000a.8a4b.6900
Cost 19
Port 8 (FastEthernet0/8)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32769 (priority 32768 sys-id-ext 1)
Address 000a.8a52.b580
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300
Interface Role Sts Cost Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Fa0/8 Root FWD 19 128.8 P2p
VLAN0002
Spanning tree enabled protocol ieee
Root ID Priority 4098
Address 000a.8a52.b580
This bridge is the root
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 4098 (priority 4096 sys-id-ext 2)
Address 000a.8a52.b580
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300
Interface Role Sts Cost Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Fa0/8 Desg FWD 19 128.8 P2p
//VLAN2的根桥变为SW1