实验目的:

1、掌握STP的基本配置。

2、理解STP的选举机制。

实验拓扑:

实验步骤:

1、依据图中拓扑部署STP技术,其中SW1为Root,SW2为Secondary,配置如下:

SW1(config)#spanning-tree vlan 1 priority 0 

SW2(config)#spanning-tree vlan 1 priority 4096 

默认情况下,网桥优先级为32768,则此时SW3上优先级为32768。STP根据越小越优先原则进行根桥选举。

2、查看网桥选举情况,如下:

SW1上:

SW1#show spanning-tree vlan 1 brief 


VLAN1

  Spanning tree enabled protocol ieee

  Root ID    Priority    0

             Address     cc05.23d8.0000

             This bridge is the root 

             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec


  Bridge ID  Priority    0

             Address     cc05.23d8.0000

             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec

             Aging Time 300


Interface                                   Designated

Name         Port ID    Prio  Cost  Sts  Cost  Bridge ID    Port ID

-------------------- ------- ---- ----- --- ----- -------------------- -------

FastEthernet0/0  128.1    128  19   FWD   0   0   cc05.23d8.0000 128.1 

FastEthernet0/1  128.2    128  19   FWD   0   0   cc05.23d8.0000 128.2 

从上面可以看出,SW1已经被选举为根桥,并且所有的接口处于转发状态。

SW2上:

SW2#show spanning-tree vlan 1 brief


VLAN1

  Spanning tree enabled protocol ieee

  Root ID    Priority    0

             Address     cc05.23d8.0000

             Cost        19

             Port        1 (FastEthernet0/0)

             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec


  Bridge ID  Priority    4096

             Address     cc06.23d8.0000

             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec

             Aging Time 300


Interface                                   Designated

Name       Port ID   Prio Cost  Sts   Cost  Bridge ID   Port ID

-------------------- ------- ---- ----- --- ----- -------------------- -------

FastEthernet0/   128.1  128  19  FWD   0   0    cc05.23d8.0000 128.1 

FastEthernet0/2  128.3  128  19  FWD  19  4096  cc06.23d8.0000 128.3

SW3上:

SW3#show spanning-tree vlan 1 brief


VLAN1

  Spanning tree enabled protocol ieee

  Root ID    Priority    0

             Address     cc05.23d8.0000

             Cost        19

             Port        2 (FastEthernet0/1)

             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec


  Bridge ID  Priority    32768

             Address     cc07.23d8.0000

             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec

             Aging Time 300


Interface                                Designated

Name         Port ID  Prio  Cost   Sts  Cost   Bridge ID  Port ID

-------------------- ------- ---- ----- --- ----- -------------------- -------

FastEthernet0/1 128.2   128   19   FWD   0    0 cc05.23d8.0000 128.2  

FastEthernet0/2 128.3    128    19  BLK    19  4096 cc06.23d8.0000 128.3

SW2的所有接口处于转发状态,SW3的优先级为32768,并且F0/2接口处于阻塞状态,用于防止环路。

3.工程用法。一般项目环境习惯直接指定网桥角色,不需要指定具体优先级,配置如下:

SW1(config)#spanning-tree vlan 1 root primary 

SW2(config)#spanning-tree vlan 1 root secondary

4、若需要修改RP和DP,可以在接口下修改链路开销值和端口优先级,配置如下:

SW1(config)#int f0/0

SW1(config-if)#spanning-tree cost ?

  <1-65535>  Change an interface's spanning tree path cost

SW1(config-if)#spanning-tree port-priority ?

  <0-255>  Change an interface's spanning tree priority

此实验完成。