This post will cover the basic configuration of STP. The labs are done on VIRL, using INE's topology.
STP works "out the box", and with default configuration, this is the resulting logical loop-free topology for this lab.
Try it out yourself if you can figure out how the spanning tree algorithm calculated the topology. As you can see, SW4 is currently the root bridge. Let's verify this on the command line.
SW1#show spanning-tree
VLAN0001
Spanning tree enabled protocol ieee
Root ID Priority 32769
Address fa16.3e27.d8f5
Cost 4
Port 4 (GigabitEthernet0/3)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32769 (priority 32768 sys-id-ext 1)
Address fa16.3e68.4cae
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 15 sec
Interface Role Sts Cost Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Gi0/1 Desg FWD 4 128.2 Shr
Gi0/2 Desg FWD 4 128.3 Shr
Gi0/3 Root FWD 4 128.4 Shr
Gi1/0 Altn BLK 4 128.5 Shr
Gi1/1 Desg FWD 4 128.6 Shr
Gi1/2 Desg FWD 4 128.7 Shr
SW2#show spanning-tree
VLAN0001
Spanning tree enabled protocol ieee
Root ID Priority 32769
Address fa16.3e27.d8f5
Cost 4
Port 2 (GigabitEthernet0/1)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32769 (priority 32768 sys-id-ext 1)
Address fa16.3ea5.285b
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300 sec
Interface Role Sts Cost Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Gi0/1 Root FWD 4 128.2 Shr
Gi0/2 Altn BLK 4 128.3 Shr
Gi0/3 Altn BLK 4 128.4 Shr
Gi1/0 Altn BLK 4 128.5 Shr
Gi1/1 Altn BLK 4 128.6 Shr
Gi1/2 Altn BLK 4 128.7 Shr
SW3#show spanning-tree
VLAN0001
Spanning tree enabled protocol ieee
Root ID Priority 32769
Address fa16.3e27.d8f5
Cost 4
Port 6 (GigabitEthernet1/1)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32769 (priority 32768 sys-id-ext 1)
Address fa16.3e83.4151
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300 sec
Interface Role Sts Cost Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Gi0/1 Altn BLK 4 128.2 Shr
Gi0/2 Altn BLK 4 128.3 Shr
Gi0/3 Desg FWD 4 128.4 Shr
Gi1/0 Desg FWD 4 128.5 Shr
Gi1/1 Root FWD 4 128.6 Shr
Gi1/2 Altn BLK 4 128.7 Shr
SW4#show spanning-tree
VLAN0001
Spanning tree enabled protocol ieee
Root ID Priority 32769
Address fa16.3e27.d8f5
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 fa16.3e27.d8f5
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300 sec
Interface Role Sts Cost Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Gi0/1 Desg FWD 4 128.2 Shr
Gi0/2 Desg FWD 4 128.3 Shr
Gi0/3 Desg FWD 4 128.4 Shr
Gi1/0 Desg FWD 4 128.5 Shr
Gi1/1 Desg FWD 4 128.6 Shr
Gi1/2 Desg FWD 4 128.7 Shr
First, configure SW1 as the new root bridge by setting the priority value to 8192. Note: the priority can only be configured in increments of 4096.
SW1(config)#spanning-tree vlan 1 priority 1
% Bridge Priority must be in increments of 4096.
% Allowed values are:
0 4096 8192 12288 16384 20480 24576 28672
32768 36864 40960 45056 49152 53248 57344 61440
SW1(config)#spanning-tree vlan 1 priority 8192
SW1(config)#do show spanning-tree
VLAN0001
Spanning tree enabled protocol ieee
Root ID Priority 8193
Address fa16.3e68.4cae
This bridge is the root
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 8193 (priority 8192 sys-id-ext 1)
Address fa16.3e68.4cae
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300 sec
Interface Role Sts Cost Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Gi0/1 Desg FWD 4 128.2 Shr
Gi0/2 Desg FWD 4 128.3 Shr
Gi0/3 Desg FWD 4 128.4 Shr
Gi1/0 Desg FWD 4 128.5 Shr
Gi1/1 Desg FWD 4 128.6 Shr
Gi1/2 Desg FWD 4 128.7 Shr
Note that the priority is actually 8193. This is because the priority consists of the priority value itself and the VLAN ID.
Next, make SW2 the root bridge by issuing the macro command. The priority value is changed to 4096 lower than the current root bridge.
SW2(config)#spanning-tree vlan 1 root primary
SW2#show spanning-tree
VLAN0001
Spanning tree enabled protocol ieee
Root ID Priority 4097
Address fa16.3ea5.285b
This bridge is the root
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 4097 (priority 4096 sys-id-ext 1)
Address fa16.3ea5.285b
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300 sec
Interface Role Sts Cost Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Gi0/1 Desg FWD 4 128.2 Shr
Gi0/2 Desg FWD 4 128.3 Shr
Gi0/3 Desg FWD 4 128.4 Shr
Gi1/0 Desg FWD 4 128.5 Shr
Gi1/1 Desg FWD 4 128.6 Shr
Gi1/2 Desg FWD 4 128.7 Shr
Gi0/3 is the root port on SW3.
SW3#show spanning-tree
VLAN0001
Spanning tree enabled protocol ieee
Root ID Priority 4097
Address fa16.3ea5.285b
Cost 4
Port 4 (GigabitEthernet0/3)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32769 (priority 32768 sys-id-ext 1)
Address fa16.3e83.4151
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300 sec
Interface Role Sts Cost Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Gi0/1 Altn BLK 4 128.2 Shr
Gi0/2 Altn BLK 4 128.3 Shr
Gi0/3 Root FWD 4 128.4 Shr
Gi1/0 Altn BLK 4 128.5 Shr
Gi1/1 Altn BLK 4 128.6 Shr
Gi1/2 Altn BLK 4 128.7 Shr
Let's change the cost of Gi1/0 to 2 to make it the root port on SW3.
Initial Configuration
The diagram below represents the physical topology for this lab.STP works "out the box", and with default configuration, this is the resulting logical loop-free topology for this lab.
Try it out yourself if you can figure out how the spanning tree algorithm calculated the topology. As you can see, SW4 is currently the root bridge. Let's verify this on the command line.
SW1#show spanning-tree
VLAN0001
Spanning tree enabled protocol ieee
Root ID Priority 32769
Address fa16.3e27.d8f5
Cost 4
Port 4 (GigabitEthernet0/3)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32769 (priority 32768 sys-id-ext 1)
Address fa16.3e68.4cae
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 15 sec
Interface Role Sts Cost Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Gi0/1 Desg FWD 4 128.2 Shr
Gi0/2 Desg FWD 4 128.3 Shr
Gi0/3 Root FWD 4 128.4 Shr
Gi1/0 Altn BLK 4 128.5 Shr
Gi1/1 Desg FWD 4 128.6 Shr
Gi1/2 Desg FWD 4 128.7 Shr
SW2#show spanning-tree
VLAN0001
Spanning tree enabled protocol ieee
Root ID Priority 32769
Address fa16.3e27.d8f5
Cost 4
Port 2 (GigabitEthernet0/1)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32769 (priority 32768 sys-id-ext 1)
Address fa16.3ea5.285b
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300 sec
Interface Role Sts Cost Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Gi0/1 Root FWD 4 128.2 Shr
Gi0/2 Altn BLK 4 128.3 Shr
Gi0/3 Altn BLK 4 128.4 Shr
Gi1/0 Altn BLK 4 128.5 Shr
Gi1/1 Altn BLK 4 128.6 Shr
Gi1/2 Altn BLK 4 128.7 Shr
SW3#show spanning-tree
VLAN0001
Spanning tree enabled protocol ieee
Root ID Priority 32769
Address fa16.3e27.d8f5
Cost 4
Port 6 (GigabitEthernet1/1)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32769 (priority 32768 sys-id-ext 1)
Address fa16.3e83.4151
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300 sec
Interface Role Sts Cost Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Gi0/1 Altn BLK 4 128.2 Shr
Gi0/2 Altn BLK 4 128.3 Shr
Gi0/3 Desg FWD 4 128.4 Shr
Gi1/0 Desg FWD 4 128.5 Shr
Gi1/1 Root FWD 4 128.6 Shr
Gi1/2 Altn BLK 4 128.7 Shr
SW4#show spanning-tree
VLAN0001
Spanning tree enabled protocol ieee
Root ID Priority 32769
Address fa16.3e27.d8f5
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 fa16.3e27.d8f5
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300 sec
Interface Role Sts Cost Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Gi0/1 Desg FWD 4 128.2 Shr
Gi0/2 Desg FWD 4 128.3 Shr
Gi0/3 Desg FWD 4 128.4 Shr
Gi1/0 Desg FWD 4 128.5 Shr
Gi1/1 Desg FWD 4 128.6 Shr
Gi1/2 Desg FWD 4 128.7 Shr
Selecting the Root Bridge
There are two ways to set the root bridge: 1) configuring the priority value directly, or 2) modifying the priority indirectly using a macro command.First, configure SW1 as the new root bridge by setting the priority value to 8192. Note: the priority can only be configured in increments of 4096.
SW1(config)#spanning-tree vlan 1 priority 1
% Bridge Priority must be in increments of 4096.
% Allowed values are:
0 4096 8192 12288 16384 20480 24576 28672
32768 36864 40960 45056 49152 53248 57344 61440
SW1(config)#spanning-tree vlan 1 priority 8192
SW1(config)#do show spanning-tree
VLAN0001
Spanning tree enabled protocol ieee
Root ID Priority 8193
Address fa16.3e68.4cae
This bridge is the root
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 8193 (priority 8192 sys-id-ext 1)
Address fa16.3e68.4cae
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300 sec
Interface Role Sts Cost Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Gi0/1 Desg FWD 4 128.2 Shr
Gi0/2 Desg FWD 4 128.3 Shr
Gi0/3 Desg FWD 4 128.4 Shr
Gi1/0 Desg FWD 4 128.5 Shr
Gi1/1 Desg FWD 4 128.6 Shr
Gi1/2 Desg FWD 4 128.7 Shr
Note that the priority is actually 8193. This is because the priority consists of the priority value itself and the VLAN ID.
Next, make SW2 the root bridge by issuing the macro command. The priority value is changed to 4096 lower than the current root bridge.
SW2(config)#spanning-tree vlan 1 root primary
SW2#show spanning-tree
VLAN0001
Spanning tree enabled protocol ieee
Root ID Priority 4097
Address fa16.3ea5.285b
This bridge is the root
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 4097 (priority 4096 sys-id-ext 1)
Address fa16.3ea5.285b
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300 sec
Interface Role Sts Cost Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Gi0/1 Desg FWD 4 128.2 Shr
Gi0/2 Desg FWD 4 128.3 Shr
Gi0/3 Desg FWD 4 128.4 Shr
Gi1/0 Desg FWD 4 128.5 Shr
Gi1/1 Desg FWD 4 128.6 Shr
Gi1/2 Desg FWD 4 128.7 Shr
Selecting the Root Port
There are two ways to influence the selection of the root port: 1) changing the interface cost to a lower value, or 2) changing the port priority to a lower value.Gi0/3 is the root port on SW3.
SW3#show spanning-tree
VLAN0001
Spanning tree enabled protocol ieee
Root ID Priority 4097
Address fa16.3ea5.285b
Cost 4
Port 4 (GigabitEthernet0/3)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32769 (priority 32768 sys-id-ext 1)
Address fa16.3e83.4151
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300 sec
Interface Role Sts Cost Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Gi0/1 Altn BLK 4 128.2 Shr
Gi0/2 Altn BLK 4 128.3 Shr
Gi0/3 Root FWD 4 128.4 Shr
Gi1/0 Altn BLK 4 128.5 Shr
Gi1/1 Altn BLK 4 128.6 Shr
Gi1/2 Altn BLK 4 128.7 Shr
Let's change the cost of Gi1/0 to 2 to make it the root port on SW3.
SW3(config)#interface GigabitEthernet1/0
SW3(config-if)#spanning-tree vlan 1 cost 2
SW3#show spanning-tree
VLAN0001
Spanning tree enabled protocol ieee
Root ID Priority 4097
Address fa16.3ea5.285b
Cost 2
Port 5 (GigabitEthernet1/0)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32769 (priority 32768 sys-id-ext 1)
Address fa16.3e83.4151
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 15 sec
Interface Role Sts Cost Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Gi0/1 Desg FWD 4 128.2 Shr
Gi0/2 Desg FWD 4 128.3 Shr
Gi0/3 Altn BLK 4 128.4 Shr
Gi1/0 Root FWD 2 128.5 Shr
Gi1/1 Desg FWD 4 128.6 Shr
Gi1/2 Desg FWD 4 128.7 Shr
Note that SW3 became the designated switch for SW1 and SW4 on their connected segments because SW3 now has a lower cost to reach the root bridge SW2.
Revert back the changes.
SW3(config)#interface GigabitEthernet1/0
SW3(config-if)#no spanning-tree vlan 1 cost 2
SW3#show spanning-tree
VLAN0001
Spanning tree enabled protocol ieee
Root ID Priority 4097
Address fa16.3ea5.285b
Cost 4
Port 4 (GigabitEthernet0/3)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32769 (priority 32768 sys-id-ext 1)
Address fa16.3e83.4151
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300 sec
Interface Role Sts Cost Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Gi0/1 Altn BLK 4 128.2 Shr
Gi0/2 Altn BLK 4 128.3 Shr
Gi0/3 Root FWD 4 128.4 Shr
Gi1/0 Altn BLK 4 128.5 Shr
Gi1/1 Altn BLK 4 128.6 Shr
Gi1/2 Altn BLK 4 128.7 Shr
Let's change the port priority value to 64.
SW3(config)#interface GigabitEthernet1/0
SW3(config-if)#spanning-tree vlan 1 port-priority 64
SW3#do show spanning-tree
VLAN0001
Spanning tree enabled protocol ieee
Root ID Priority 4097
Address fa16.3ea5.285b
Cost 4
Port 4 (GigabitEthernet0/3)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32769 (priority 32768 sys-id-ext 1)
Address fa16.3e83.4151
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300 sec
Interface Role Sts Cost Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Gi0/1 Altn BLK 4 128.2 Shr
Gi0/2 Altn BLK 4 128.3 Shr
Gi0/3 Root FWD 4 128.4 Shr
Gi1/0 Altn BLK 4 64.5 Shr
Gi1/1 Altn BLK 4 128.6 Shr
Gi1/2 Altn BLK 4 128.7 Shr
Note that this did nothing to change the root port. Gi1/0 is still blocking. This is because the tie-breaking decision is actually based on the designated port ID found in the received BPDU.
SW3#show spanning-tree vlan 1 interface GigabitEthernet1/0 detail
Port 5 (GigabitEthernet1/0) of VLAN0001 is alternate blocking
Port path cost 4, Port priority 64, Port Identifier 64.5.
Designated root has priority 4097, address fa16.3ea5.285b
Designated bridge has priority 4097, address fa16.3ea5.285b
Designated port id is 128.5, designated path cost 0
Timers: message age 2, forward delay 0, hold 0
Number of transitions to forwarding state: 3
Link type is shared by default
BPDU: sent 872, received 831
Let's change the priority of G1/0 on SW2.
SW2(config)#interface GigabitEthernet1/0
SW2(config-if)#spanning-tree vlan 1 port-priority 64
The root port on SW3 has now changed.
SW3#show spanning-tree
VLAN0001
Spanning tree enabled protocol ieee
Root ID Priority 4097
Address fa16.3ea5.285b
Cost 4
Port 5 (GigabitEthernet1/0)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32769 (priority 32768 sys-id-ext 1)
Address fa16.3e83.4151
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 15 sec
Interface Role Sts Cost Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Gi0/1 Altn BLK 4 128.2 Shr
Gi0/2 Altn BLK 4 128.3 Shr
Gi0/3 Altn BLK 4 128.4 Shr
Gi1/0 Root FWD 4 128.5 Shr
Gi1/1 Altn BLK 4 128.6 Shr
Gi1/2 Altn BLK 4 128.7 Shr
SW3#show spanning-tree vlan 1 interface GigabitEthernet1/0 detail
Port 5 (GigabitEthernet1/0) of VLAN0001 is root forwarding
Port path cost 4, Port priority 128, Port Identifier 128.5.
Designated root has priority 4097, address fa16.3ea5.285b
Designated bridge has priority 4097, address fa16.3ea5.285b
Designated port id is 64.5, designated path cost 0
Timers: message age 2, forward delay 0, hold 0
Number of transitions to forwarding state: 4
Link type is shared by default
BPDU: sent 873, received 923
Tuning STP Timers
The root bridge dictates the STP timers, regardless of what is configured on the switch itself.
Let's keep the default timers on SW1 and change them on the root bridge SW2, then watch how often SW1 sends BPDUs (Hello Time).
SW2(config)#spanning-tree vlan 1 hello-time 10
SW2(config)#spanning-tree vlan 1 forward-time 30
SW2(config)#spanning-tree vlan 1 max-age 40
SW1#show spanning-tree
VLAN0001
Spanning tree enabled protocol ieee
Root ID Priority 4097
Address fa16.3ea5.285b
Cost 4
Port 6 (GigabitEthernet1/1)
Hello Time 10 sec Max Age 40 sec Forward Delay 30 sec
Bridge ID Priority 8193 (priority 8192 sys-id-ext 1)
Address fa16.3e68.4cae
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300 sec
Interface Role Sts Cost Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Gi0/1 Desg FWD 4 128.2 Shr
Gi0/2 Desg FWD 4 128.3 Shr
Gi0/3 Desg FWD 4 128.4 Shr
Gi1/0 Desg FWD 4 128.5 Shr
Gi1/1 Root FWD 4 128.6 Shr
Gi1/2 Altn BLK 4 128.7 Shr
SW1#debug spanning-tree bpdu transmit
Spanning Tree BPDU Transmitted debugging is on
SW1#
*Oct 14 14:10:56.527: STP: VLAN0001 Gi0/1 tx BPDU: config protocol=ieee
*Oct 14 14:11:06.522: STP: VLAN0001 Gi0/1 tx BPDU: config protocol=ieee
*Oct 14 14:11:16.523: STP: VLAN0001 Gi0/1 tx BPDU: config protocol=ieee
As you can see from the timestamps, SW1 is sending BPDUs at 10-second intervals, although its configured Hello Time is still the default 2 seconds.
Comments
Post a Comment