实验48: STPPVST

1. 实验目的

通过本实验,读者可以掌握如下技能:

1 理解STP 的工作原理

2 掌握STP 树的控制

3 利用PVST 进行负载平衡

 

2. 实验拓扑

拓扑图

3. 实验步骤

我们要在网络中配置2 VLAN,不同VLAN STP 具有不同的根桥,实现负载平衡。

sw1(config)#int f0/0
sw1(config-if)#switch trunk enca d
*Mar  1 00:07:22.347: %SPANTREE-2-UNBLOCK_CONSIST_PORT: Unblocking FastEthernet0/2 on VLAN1. Port consistency restored.
sw1(config-if)#switch trunk enca dot1q
sw1(config-if)#switch mode trunk//以上是配置TRUNK
sw1(config-if)#exit
sw1(config)#int f0/2
sw1(config-if)#switch trunk enca dot1q
sw1(config-if)#switch mode trunk     
sw1(config-if)#
*Mar  1 00:07:55.527: %DTP-5-TRUNKPORTON: Port Fa0/2 has become dot1q trunk
sw1(config-if)#exit
sw1(config)#exit
sw1#val
*Mar  1 00:08:07.995: %SYS-5-CONFIG_I: Configured from console by console
sw1#vlan dat
sw1(vlan)#vtp domain cisco//配置VTP域名CISCO
Changing VTP domain name from NULL to cisco
sw1(vlan)#vlan 2 name ke //创建VLAN2
VLAN 2 added:
    Name: ke
sw1(vlan)#exit
APPLY completed.
Exiting....
sw1#sh vtp sta//查看VTP的状态,同时也在SW2/3查看,SW1 上配置VTP 的域名,并创建VLAN 2。由于默认时SW2 SW3 VTP 域名为空,它们将自动学习到S1 VTP 域名,同时S2S3 也将自动学习到VLAN 2,请确认是否成功。

 

VTP Version                     : 2
Configuration Revision          : 1
Maximum VLANs supported locally : 256
Number of existing VLANs        : 6
VTP Operating Mode              : Server
VTP Domain Name                 : cisco

VTP Pruning Mode                : Disabled
VTP V2 Mode                     : Disabled
VTP Traps Generation            : Disabled
MD5 digest                      : 0x2A 0xC4 0x64 0xED 0x91 0xFB 0x56 0x88
Configuration last modified by 0.0.0.0 at 3-1-02 00:08:47
Local updater ID is 0.0.0.0 (no valid interface found)
sw1#sh vlan-switch//GNS3上要用show vlan-switch来查看VLAN信息,而真实的设备要用SHOW VLAN VLAN-ID

 

VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Fa0/1, Fa0/3, Fa0/4, Fa0/5
                                                Fa0/6, Fa0/7, Fa0/8, Fa0/9
                                                Fa0/10, Fa0/11, Fa0/12, Fa0/13
                                                Fa0/14, Fa0/15
2    ke                               active   

1002 fddi-default                     active   
1003 token-ring-default               active   
1004 fddinet-default                  active   
1005 trnet-default                    active   

 

VLAN Type  SAID       MTU   Parent RingNo BridgeNo Stp  BrdgMode Trans1 Trans2
---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------
1    enet  100001     1500  -      -      -        -    -        1002   1003
2    enet  100002     1500  -      -      -        -    -        0      0  
1002 fddi  101002     1500  -      -      -        -    -        1      1003
1003 tr    101003     1500  1005   0      -        -    srb      1      1002
1004 fdnet 101004     1500  -      -      1        ibm  -        0      0  
1005 trnet 101005     1500  -      -      1        ibm  -        0      0  
sw1#sh spanning-tree检查初始的STP

 

 

 VLAN1 is executing the ieee compatible Spanning Tree protocol
  Bridge Identifier has priority 32768, address cc00.13f0.0000

默认的优先级为32768

  Configured hello time 2, max age 20, forward delay 15
  We are the root of the spanning tree//SW1是根网桥

  Topology change flag not set, detected flag not set
  Number of topology changes 3 last change occurred 00:07:36 ago
          from FastEthernet0/2
  Times:  hold 1, topology change 35, notification 2
          hello 2, max age 20, forward delay 15
  Timers: hello 0, topology change 0, notification 0, aging 300

 

 

 

         
         
 VLAN2 is executing the ieee compatible Spanning Tree protocol
  Bridge Identifier has priority 32768, address cc00.13f0.0001
  Configured hello time 2, max age 20, forward delay 15
  We are the root of the spanning tree
  Topology change flag not set, detected flag not set
  Number of topology changes 1 last change occurred 00:05:36 ago
          from FastEthernet0/0
  Times:  hold 1, topology change 35, notification 2
          hello 2, max age 20, forward delay 15
  Timers: hello 1, topology change 0, notification 0, aging 300
         
         
 
  //以上是VLAN 2 STP 树情况,VLAN 2 STP 树和VLAN 1 的类似。默认时,Cisco 交换机

会为每个VLAN 都生成一个单独的STP 树,称为PVST(Per VLAN Spanning Tree)

       
sw1#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
sw1(config)#spanning-tree  vlan 2 priority 10000  改变VLAN2的优先级,让VLAN2SW1成为根网桥

sw1(config)#do sh spann

 

 VLAN1 is executing the ieee compatible Spanning Tree protocol
  Bridge Identifier has priority 32768, address cc00.13f0.0000
  Configured hello time 2, max age 20, forward delay 15
  Current root has priority 10000, address cc01.13f0.0000
  Root port is 1 (FastEthernet0/0), cost of root path is 19
  Topology change flag not set, detected flag not set
  Number of topology changes 3 last change occurred 00:19:36 ago
          from FastEthernet0/2
  Times:  hold 1, topology change 35, notification 2
          hello 2, max age 20, forward delay 15
  Timers: hello 0, topology change 0, notification 0, aging 300
可以看到VLAN1 SW1已经不是根网桥了。

 

 

 
         
         
 VLAN2 is executing the ieee compatible Spanning Tree protocol
  Bridge Identifier has priority 10000, address cc00.13f0.0001
  Configured hello time 2, max age 20, forward delay 15
  We are the root of the spanning tree VLAN2SW1成为根网桥

 

  Topology change flag not set, detected flag not set
 --More—

 

 

 

sw2(config)#int f0/0
sw2(config-if)#switch trunk enca dot1q
sw2(config-if)#switch mode trunk
sw2(config-if)#e
*Mar  1 00:04:19.151: %DTP-5-TRUNKPORTON: Port Fa0/0 has become dot1q trunk
sw2(config-if)#exit
sw2(config)#int f0/1
sw2(config-if)#switch trunk enca dot1q
sw2(config-if)#switch mode trunk     
sw2(config-if)#
*Mar  1 00:04:35.239: %DTP-5-TRUNKPORTON: Port Fa0/1 has become dot1q trunk
sw2(config-if)#do sh vlan-switch

 

VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Fa0/2, Fa0/3, Fa0/4, Fa0/5
                                                Fa0/6, Fa0/7, Fa0/8, Fa0/9
                                                Fa0/10, Fa0/11, Fa0/12, Fa0/13
                                                Fa0/14, Fa0/15
2    ke                               active   

1002 fddi-default                     active   
1003 token-ring-default               active   
1004 fddinet-default                  active   
1005 trnet-default                    active   

 

VLAN Type  SAID       MTU   Parent RingNo BridgeNo Stp  BrdgMode Trans1 Trans2
---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------
1    enet  100001     1500  -      -      -        -    -        1002   1003
2    enet  100002     1500  -      -      -        -    -        0      0  
1002 fddi  101002     1500  -      0      -        -    -        1      1003
1003 tr    101003     1500  1005   0      -        -    srb      1      1002
1004 fdnet 101004     1500  -      -      1        ibm  -        0      0  
1005 trnet 101005     1500  -      -      1        ibm  -        0      0  
sw2(config-if)#do sh vtp sta
VTP Version                     : 2
Configuration Revision          : 1
Maximum VLANs supported locally : 256
Number of existing VLANs        : 6
VTP Operating Mode              : Server
VTP Domain Name                 : cisco//已经更新了VLAN信息了。

VTP Pruning Mode                : Disabled
VTP V2 Mode                     : Disabled
VTP Traps Generation            : Disabled
MD5 digest                      : 0x2A 0xC4 0x64 0xED 0x91 0xFB 0x56 0x88
Configuration last modified by 0.0.0.0 at 3-1-02 00:08:47
Local updater ID is 0.0.0.0 (no valid interface found)
sw2(config-if)#do sh spanning

 

 VLAN1 is executing the ieee compatible Spanning Tree protocol
  Bridge Identifier has priority 32768, address cc01.13f0.0000
  Configured hello time 2, max age 20, forward delay 15
  Current root has priority 32768, address cc00.13f0.0000
  Root port is 1 (FastEthernet0/0), cost of root path is 19
  Topology change flag not set, detected flag not set
  Number of topology changes 7 last change occurred 00:10:30 ago
          from FastEthernet0/1
  Times:  hold 1, topology change 35, notification 2
          hello 2, max age 20, forward delay 15
  Timers: hello 0, topology change 0, notification 0, aging 300

 

 Port 1 (FastEthernet0/0) of VLAN1 is forwarding
   Port path cost 19, Port priority 128, Port Identifier 128.1.
   Designated root has priority 32768, address cc00.13f0.0000
   Designated bridge has priority 32768, address cc00.13f0.0000
   Designated port id is 128.1, designated path cost 0
   Timers: message age 2, forward delay 0, hold 0
   Number of transitions to forwarding state: 1
   BPDU: sent 4, received 342

 

 
         
         
 VLAN2 is executing the ieee compatible Spanning Tree protocol
  Bridge Identifier has priority 32768, address cc01.13f0.0001
  Configured hello time 2, max age 20, forward delay 15
  Current root has priority 32768, address cc00.13f0.0001
  Root port is 1 (FastEthernet0/0), cost of root path is 19
  Topology change flag not set, detected flag not set
  Number of topology changes 1 last change occurred 00:06:25 ago
          from FastEthernet0/0
  Times:  hold 1, topology change 35, notification 2
          hello 2, max age 20, forward delay 15
  Timers: hello 0, topology change 0, notification 0, aging 300
         
 
sw2(config-if)#exit

 

sw2(config)#spanning-tree vlan 1 priority 10000 改变VLAN1的优先级,让SW2VLAN1中成为根网桥

sw2(config)#do sh span

 

 VLAN1 is executing the ieee compatible Spanning Tree protocol
  Bridge Identifier has priority 10000, address cc01.13f0.0000
  Configured hello time 2, max age 20, forward delay 15
  We are the root of the spanning tree//SW2已经变为了根网桥。

  Topology change flag not set, detected flag not set
  Number of topology changes 8 last change occurred 00:02:56 ago
  Times:  hold 1, topology change 35, notification 2
          hello 2, max age 20, forward delay 15
  Timers: hello 1, topology change 0, notification 0, aging 300

 

 

 

 

 

w3(config)#int f0/1
sw3(config-if)#switch trunk enca dot1q
sw3(config-if)#switch mode trunk
sw3(config-if)#
*Mar  1 00:06:44.879: %DTP-5-TRUNKPORTON: Port Fa0/1 has become dot1q trunk
sw3(config-if)#exit
sw3(config)#int f0/2
sw3(config-if)#switch trunk enca dot1q
sw3(config-if)#switch mode trunk     
sw3(config-if)#
*Mar  1 00:07:05.223: %DTP-5-TRUNKPORTON: Port Fa0/2 has become dot1q trunk
sw3(config-if)#do sh vlan-switch

 

VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Fa0/0, Fa0/3, Fa0/4, Fa0/5
                                                Fa0/6, Fa0/7, Fa0/8, Fa0/9
                                                Fa0/10, Fa0/11, Fa0/12, Fa0/13
                                                Fa0/14, Fa0/15
2    ke                               active   

1002 fddi-default                     active   
1003 token-ring-default               active   
1004 fddinet-default                  active   
1005 trnet-default                    active   

 

VLAN Type  SAID       MTU   Parent RingNo BridgeNo Stp  BrdgMode Trans1 Trans2
---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------
1    enet  100001     1500  -      -      -        -    -        1002   1003
2    enet  100002     1500  -      -      -        -    -        0      0  
1002 fddi  101002     1500  -      0      -        -    -        1      1003
1003 tr    101003     1500  1005   0      -        -    srb      1      1002
1004 fdnet 101004     1500  -      -      1        ibm  -        0      0  
1005 trnet 101005     1500  -      -      1        ibm  -        0      0  
sw3(config-if)#do sh vtp sta
VTP Version                     : 2
Configuration Revision          : 1
Maximum VLANs supported locally : 256
Number of existing VLANs        : 6
VTP Operating Mode              : Server
VTP Domain Name                 : cisco

VTP Pruning Mode                : Disabled
VTP V2 Mode                     : Disabled
VTP Traps Generation            : Disabled
MD5 digest                      : 0x2A 0xC4 0x64 0xED 0x91 0xFB 0x56 0x88
Configuration last modified by 0.0.0.0 at 3-1-02 00:08:47
Local updater ID is 0.0.0.0 (no valid interface found)