Saturday, September 21, 2013

Spanning Tree Protocol (STP) Lab

At last, I got my 8-port Catalyst 2940 switch. This would be the final piece to complete my switching lab. This is the baby brother of the Catalyst 2950, which is the most deployed and practical switch in both production and lab environments. I just can't help not buying this cute and awesome device.

 
Since I've gathered all my switches, I'm now able to create Spanning-Tree Protocol (STP) and VLAN Trunking Protocol (VTP) lab using the famous "switch triangle" topology. This topology makes more meaningful and challenging STP and VTP lab as compared to a single or switch pair topology.


We start by configuring the EtherChannel and trunk links on the C3560 first, on the C2960 and finally on the C2940.

Switch#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#hostname SW1
SW1(config)#do show interface status

Port      Name               Status       Vlan       Duplex  Speed Type
Fa0/1                        notconnect   1            auto   auto 10/100BaseTX
Fa0/2                        notconnect   1            auto   auto 10/100BaseTX
Fa0/3                        notconnect   1            auto   auto 10/100BaseTX
Fa0/4                        notconnect   1            auto   auto 10/100BaseTX
Fa0/5                        notconnect   1            auto   auto 10/100BaseTX
Fa0/6                        notconnect   1            auto   auto 10/100BaseTX
Fa0/7                        notconnect   1            auto   auto 10/100BaseTX
Fa0/8                        notconnect   1            auto   auto 10/100BaseTX
Gi0/1                        notconnect   1            auto   auto Not Present
SW1(config)#interface range fastethernet0/1-2
SW1(config-if-range)#switchport mode trunk
Command rejected: An interface whose trunk encapsulation is "Auto" can not be configured to "trunk" mode.
Command rejected: An interface whose trunk encapsulation is "Auto" can not be configured to "trunk" mode.
// THIS ERROR HAPPENS TO APPEAR IN 3560
SW1(config-if-range)#switchport trunk encapsulation ?
  dot1q      Interface uses only 802.1q trunking encapsulation when trunking
  isl        Interface uses only ISL trunking encapsulation when trunking
  negotiate  Device will negotiate trunking encapsulation with peer on
             interface
SW1(config-if-range)#switchport trunk encapsulation dot1q
SW1(config-if-range)#switchport mode trunk
SW1(config-if-range)#end

----

Switch#configure terminal
*Mar  1 00:02:43.854: %LINK-5-CHANGED: Interface Vlan1, changed state to administratively down
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#hostname SW3
SW3(config)#do show interface status

Port      Name               Status       Vlan       Duplex  Speed Type
Fa0/1                        notconnect   1            auto   auto 10/100BaseTX
Fa0/2                        notconnect   1            auto   auto 10/100BaseTX
Fa0/3                        notconnect   1            auto   auto 10/100BaseTX
Fa0/4                        notconnect   1            auto   auto 10/100BaseTX
Fa0/5                        notconnect   1            auto   auto 10/100BaseTX
Fa0/6                        notconnect   1            auto   auto 10/100BaseTX
Fa0/7                        notconnect   1            auto   auto 10/100BaseTX
Fa0/8                        notconnect   1            auto   auto 10/100BaseTX
Gi0/1                        notconnect   1            auto   auto 10/100/1000BaseTX
SW3(config)#interface range fastethernet0/1-2
SW3(config-if-range)#switchport mode trunk
SW3(config-if-range)#end

----

Switch#configure terminal
00:02:36: %LINK-5-CHANGED: Interface Vlan1, changed state to administratively down
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#hostname SW2
SW2(config)#do sh int status

Port      Name               Status       Vlan       Duplex  Speed Type
Fa0/1                        notconnect   1            auto   auto 10/100BaseTX
Fa0/2                        notconnect   1            auto   auto 10/100BaseTX
Fa0/3                        notconnect   1            auto   auto 10/100BaseTX
Fa0/4                        notconnect   1            auto   auto 10/100BaseTX
Fa0/5                        notconnect   1            auto   auto 10/100BaseTX
Fa0/6                        notconnect   1            auto   auto 10/100BaseTX
Fa0/7                        notconnect   1            auto   auto 10/100BaseTX
Fa0/8                        notconnect   1            auto   auto 10/100BaseTX
Gi0/1                        notconnect   1            auto   auto 10/100/1000BaseTX
SW2(config)#interface range fastethernet0/1-2
                                           ^
% Invalid input detected at '^' marker.    // 2940 NEEDS A SPACE ON INTERFACE RANGE COMMAND

SW2(config)#interface range fastethernet0/1 - 2
SW2(config-if-range)#switchport mode trunk
SW2(config-if-range)#end


STP is enabled by default on switches (for VLAN 1) and we can quickly verify its operation by using the show spanning-tree command. From here we could see the Bridge ID (priority and MAC address) and the elected root bridge. All switches have a default priority of 32768 and the lower value has the highest priority (which in this case a value of 1).

If all switches have the same priority and extended system ID, the one with the lowest MAC address will be considered the root bridge. Notice that SW1's F0/2 port state is blocked (BLK) since it has the highest MAC address. It also considered this port to be redundant towards the root bridge.

SW2 (C2940) became the root bridge since it has the lowest MAC address compared to the other switches. Also noticed all of its ports are in the forwarding (FWD) state, which is the reward for a root bridge.

SW1#show spanning-tree ?
  active             Report on active interfaces only
  backbonefast       Show spanning tree backbonefast status
  blockedports       Show blocked ports
  bridge             Status and configuration of this bridge
  detail             Detailed information
  inconsistentports  Show inconsistent ports
  interface          Spanning Tree interface status and configuration
  mst                Multiple spanning trees
  pathcost           Show Spanning pathcost options
  root               Status and configuration of the root bridge
  summary            Summary of port states
  uplinkfast         Show spanning tree uplinkfast status
  vlan               VLAN Switch Spanning Trees
  |                  Output modifiers
  <cr>

SW1#show spanning-tree

VLAN0001
  Spanning tree enabled protocol ieee
  Root ID    Priority    32769
             Address     001b.0db0.8f00   // MAC ADDRESS OF C2940
             Cost        19
             Port        2 (FastEthernet0/1)
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec

  Bridge ID  Priority    32769  (priority 32768 sys-id-ext 1)
             Address     6416.8dec.a700    // MAC ADDRESS OF C3560
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time 300

Interface        Role Sts Cost      Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/1            Root FWD 19        128.2    P2p
Fa0/2            Altn BLK 19        128.3    P2p


SW3#show spanning-tree

VLAN0001
  Spanning tree enabled protocol ieee
  Root ID    Priority    32769
             Address     001b.0db0.8f00
             Cost        19
             Port        2 (FastEthernet0/2)
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec

  Bridge ID  Priority    32769  (priority 32768 sys-id-ext 1)
             Address     001f.9d88.b980   // MAC ADDRESS OF C2960
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time 300

Interface           Role Sts Cost      Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Fa0/1               Desg FWD 19        128.1    P2p
Fa0/2               Root FWD 19        128.2    P2p


SW2#show spanning-tree

VLAN0001
  Spanning tree enabled protocol ieee
  Root ID    Priority    32769
             Address     001b.0db0.8f00   // MAC ADDRESS OF C2940
             This bridge is the root
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec

  Bridge ID  Priority    32769  (priority 32768 sys-id-ext 1)
             Address     001b.0db0.8f00
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time 300

Interface        Role Sts Cost      Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/1            Desg FWD 19        128.1    P2p
Fa0/2            Desg FWD 19        128.2    P2p


Since the C2940 has the lowest switching capacity, we could force the C3560 to be the primary root bridge and the C2960 as the secondary root bridge. We do this by issuing the commands spanning-tree vlan 1 root primary and spanning-tree vlan 1 root secondary in global config mode. Notice the priority for primary root and secondary root bridge became 24577 and 28673 respectively (multiples of 4096) and the C2940 F0/2 port went to a blocking state.

SW1#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
SW1(config)#spanning-tree ?
  backbonefast  Enable BackboneFast Feature
  etherchannel  Spanning tree etherchannel specific configuration
  extend        Spanning Tree 802.1t extensions
  logging       Enable Spanning tree logging
  loopguard     Spanning tree loopguard options
  mode          Spanning tree operating mode
  mst           Multiple spanning tree configuration
  pathcost      Spanning tree pathcost options
  portfast      Spanning tree portfast options
  transmit      STP transmit parameters
  uplinkfast    Enable UplinkFast Feature
  vlan          VLAN Switch Spanning Tree

SW1(config)#spanning-tree vlan ?
  WORD  vlan range, example: 1,3-5,7,9-11

SW1(config)#spanning-tree vlan 1 ?
  forward-time  Set the forward delay for the spanning tree
  hello-time    Set the hello interval for the spanning tree
  max-age       Set the max age interval for the spanning tree
  priority      Set the bridge priority for the spanning tree
  root          Configure switch as root
  <cr>

SW1(config)#spanning-tree vlan 1 root ?
  primary    Configure this switch as primary root for this spanning tree
  secondary  Configure switch as secondary root

SW1(config)#spanning-tree vlan 1 root primary
SW1(config)#end
00:14:19: %SYS-5-CONFIG_I: Configured from console by console
SW1#show spaning-tree

VLAN0001
  Spanning tree enabled protocol ieee
  Root ID    Priority    24577
             Address     6416.8dec.a700
             This bridge is the root
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec

  Bridge ID  Priority    24577  (priority 24576 sys-id-ext 1)
             Address     6416.8dec.a700
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time 15

Interface        Role Sts Cost      Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/1            Desg FWD 19        128.2    P2p
Fa0/2            Desg FWD 19        128.3    P2p


SW3#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
SW3(config)#spanning-tree vlan 1 root ?
  primary    Configure this switch as primary root for this spanning tree
  secondary  Configure switch as secondary root

SW3(config)#spanning-tree vlan 1 root secondary
SW3(config)#end
SW3#show spanning-tree

VLAN0001
  Spanning tree enabled protocol ieee
  Root ID    Priority    24577
             Address     6416.8dec.a700
             Cost        19
             Port        1 (FastEthernet0/1)
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec

  Bridge ID  Priority    28673  (priority 28672 sys-id-ext 1)
             Address     001f.9d88.b980
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time 15

Interface           Role Sts Cost      Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Fa0/1               Root FWD 19        128.1    P2p
Fa0/2               Desg FWD 19        128.2    P2p


SW2#show spanning-tree

VLAN0001
  Spanning tree enabled protocol ieee
  Root ID    Priority    24577
             Address     6416.8dec.a700
             Cost        19
             Port        1 (FastEthernet0/1)
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec

  Bridge ID  Priority    32769  (priority 32768 sys-id-ext 1)
             Address     001b.0db0.8f00
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time 15

Interface        Role Sts Cost      Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/1            Root FWD 19        128.1    P2p
Fa0/2            Altn BLK 19        128.2    P2p


Just for fun and be able observe an STP loop, I've disabled spanning-tree on all switches using the no spanning-tree vlan 1 command. It could be observed on the last few seconds of the video that the LED lights went fuzzy and CPU utilization shoots up in just a few seconds.

SW1#show processes cpu sorted
CPU utilization for five seconds: 41%/6%; one minute: 21%; five minutes: 8%
 PID Runtime(ms)   Invoked      uSecs   5Sec   1Min   5Min TTY Process
 161       12391     22199        558 30.03% 13.42%  3.35%   0 Spanning Tree
 155          85       131        648  0.31%  0.07%  0.01%   0 Exec
   2           0      1060          0  0.00%  0.00%  0.00%   0 Load Meter
   1           0         3          0  0.00%  0.00%  0.00%   0 Chunk Manager
   3           0        14          0  0.00%  0.00%  0.00%   0 SpanTree Helper

No comments:

Post a Comment