Kole's Networking Journey

STP Lab

Today I wanted to play around with setting up spanning tree in a lab. I began by setting up a simple topology in PacketTracer with 3 switches:

I enabled STP on Switch 1 by creating a VLAN and enabling spanning Tree on that VLAN. This immediately put the topology in a spanning-tree instance, putting Switch 1 as the root port and blocking the Fa0/2 interface on Switch 2. This should prevent loops in this environment.

I confirmed the status by using the show spanning-tree command on Switch 2:

The output lists Switch 1's MAC address as the root and shows SW2's Fa0/2 interface as Blocking.

Next, I wanted to try changing the root bridge election by modifying the bridge priority value. This can be done by either issuing the spanning-tree vlan # root primary command or spanning-tree vlan # priority value command. I believe the later command is preferred as it is best to statically set the value so you can be absolutely sure you get the correct root bridge. The root primary command changes the default priority value to be 24576, but if a new switch with lower priority comes in to the network, the newer switch will become root. Therefore is best to manually set the value so you can be sure of where the root bridge will be.

I decided I wanted to make Switch 3 the root, so I changed the priority to 20480 (Must be increments of 4096).

Confirmation that priority is changed and SW3 has become the root:

Next I wanted to try configuring some STP optional features such as PortFast and BPDU guard.

PortFast allows a port to immediately transition to the forwarding state upon being connected. This is useful for access ports that are connected to end hosts. To test this out I added a PC to the environment and enabled PortFast on the port with the spanning-tree portfast command:

Once enabled the port immediately was brought into the forwarding state.

Finally, I wanted to test out BPDU guard. BPDU Guard prevents unwanted switches from connecting to specific ports to avoid unwanted switches becoming the root bridge. BPDU guard can be enabled globally or on a per-port basis.

I went on SW3 and enabled BPDU guard globally with the spanning-tree portfast bpduguard default command. I then added another switch to the topology connected to SW3's Fa0/4 interface. After the moment the port went down and transitioned to the err-disabled state. It seems that BPDU Guard is working correctly.

This can be further verified with the show interfaces status command. The output shows fa0/4 in the err-disabled state as it had triggered BPDU guard.

Current topology:

For some extra practice I decided to expand the network by adding two more switches, creating a full access and distribution layer. It is best practice to have one of the more central/core switches be the root bridge so in this case it should either be SW1 or the newly added SW5. In this case I decided to go with switch 5. I decided to set SW5's priority to be 16,384, which is lower than SW3 so it would then be elected as the root bridge.

After some time, the topology eventually reconverges and SW5 is now the root. Doing this makes the downsides of STP very noticeable as it took nearly a minute for the network to change over. This is why RSTP is necessary and the current standard.

Here is confirmation of SW5's root election:

Final topology:

Created with © systeme.io