Hi everyone, in an office network the switches are usually connected with more than one path, so if one cable breaks the network keeps running. The catch is that redundant paths between switches can make broadcasts circle around endlessly. This is called a switching loop, and it can bring the whole network to a standstill. STP (Spanning Tree Protocol) prevents this by blocking one of the paths and only opening it again when the main path goes down.
In this article I practice STP with 3 switches arranged in a triangle in Cisco Packet Tracer 8.2.1. We will see which port gets blocked, set the root bridge manually, and then test failover by cutting one cable. If Cisco switches are still new to you, read my guide on Cisco switch configuration in Packet Tracer first.
The Topology and Cables Used
Three switches forming a triangle

The lab uses 3 Cisco 2960-24TT switches and 2 PCs. Every switch is connected to the other two, so there are two paths from Switch0 to Switch1: the direct link, or the detour through Switch2.

The light orange box marks the switch triangle that can create a loop, and the note next to it says that a triangle of 3 switches means there is a backup path. PC0 on Switch0 uses the IP 10.10.10.1, and PC1 on Switch1 uses 10.10.10.2.
Switch0 Gig0/1 -> Switch1 Gig0/1 (cross-over)
Switch0 Gig0/2 -> Switch2 Gig0/1 (cross-over)
Switch1 Gig0/2 -> Switch2 Gig0/2 (cross-over)
PC0 FastEthernet0 -> Switch0 Fa0/1 (straight)
PC1 FastEthernet0 -> Switch1 Fa0/1 (straight)The switch to switch links use Copper Cross-Over because they connect devices of the same kind, while the PC to switch links use Copper Straight-Through.
STP Works Automatically
One port turns orange

Without any configuration at all, after about 30 seconds every port light turns green except one: Gig0/1 on Switch2, which stays orange. In Packet Tracer, orange means the port is being blocked by STP. With that one port blocked, the triangle no longer forms a loop.
Open the Switch2 CLI

Click Switch2 at the bottom of the triangle.

Click the CLI tab, then press Enter until the Switch> prompt appears.
Check the spanning tree status

enable
show spanning-treeThe Root ID section shows the address of the root bridge, which is the switch at the center of STP. The switch with the lowest priority is chosen automatically, and when the priorities are equal like here (32769), the switch with the lowest MAC address wins. So right now the root bridge is Switch1.
Further down you can see Gi0/2 with the role Root FWD, the best path toward the root, while Gi0/1 has the role Altn BLK, an alternate path that is blocked.
Setting the Root Bridge Manually
Letting the root bridge be picked by the lowest MAC address is not ideal, because the winner could be the oldest or weakest switch. In a real network, the root bridge should be the most powerful core switch.
Open the Switch0 CLI

Close the Switch2 window, then click Switch0 at the top left and open the CLI tab.
Make Switch0 the root bridge

enable
configure terminal
spanning-tree vlan 1 root primary
end
write memoryThe root primary command lowers the priority of Switch0 below the other switches, so Switch0 gets elected as the root bridge for VLAN 1.
Check the new root bridge

Wait about 30 seconds, then run the following command on Switch0.
show spanning-treeNow it says This bridge is the root with a priority of 24577. Every port on the root bridge has the role Desg FWD, because a root bridge never blocks its own ports.
The blocked port moves

Take another look at the topology. Since the root bridge changed, STP recalculated the best paths.

The orange port is now Gig0/2 on Switch2, which is the Switch2 to Switch1 link that is farthest from the root. Gig0/1 on Switch2, the one that was blocked earlier, is now green.
Testing Failover
Ping from PC0 to PC1

Set the PC0 IP to 10.10.10.1 and the PC1 IP to 10.10.10.2, both with the subnet mask 255.255.255.0. Then open the Command Prompt on PC0.

ping 10.10.10.2The ping succeeds over the direct path from Switch0 to Switch1.
Cut the cable between Switch0 and Switch1

First click an empty area so no device is selected, choose the Delete tool, then click the cable between Switch0 and Switch1. Wait about 30 seconds.

Port Gig0/2 on Switch2, which was orange before, turns green. STP opened the backup path because the main path is gone.
The ping still works over the backup path

Run the ping from PC0 to PC1 again. It still succeeds, and this time the packets travel through Switch0, Switch2, and then Switch1. In the lab file you can download above, I have already reconnected the Switch0 to Switch1 cable.
Common Problems and How to Fix Them
The port light stays orange for a while after plugging in a cable
This is normal. STP needs about 30 seconds to go through the listening and learning stages before the port starts forwarding data. For ports connected to a PC, you can cut this wait with spanning-tree portfast.
The root bridge does not change after root primary
Make sure you typed the command for the right VLAN. Each VLAN runs its own STP, so root primary for vlan 1 does not apply to other VLANs.
The PC port turns orange too
PC ports go through the same process for about 30 seconds. If it is still orange after that, check the cable and make sure the port is not shut down.
At this point the switch triangle is loop free, we can choose the root bridge ourselves, and the network keeps running when one cable breaks. In the next article we cover EtherChannel, a way to bundle several cables between switches into one faster link without STP blocking any of them. If you run into any other error while trying this, just leave a comment below.












