18 min read

Spanning Tree Explained: STP, RSTP, and MST

How STP, RSTP, and MST keep Ethernet loop free, and the commands to audit root bridges, port roles, and blocked links on switches you run today.

ByAndré Ribeiro· Founder, Obelinf
Spanning Tree Explained: STP, RSTP, and MST
Spanning Tree Explained: STP, RSTP, and MST · November 24, 2026
On this page

A network with redundant links is a network that stays up when a cable, an optic, or an entire switch fails. It is also a network that will destroy itself in seconds, because Ethernet has no time to live field. A broadcast frame that arrives on two ports is flooded out of every other port, arrives back on the first switch through the second path, and repeats. Each pass doubles the copies, the MAC address table churns as the same source appears on alternating ports, and the links that were supposed to add resilience saturate with their own traffic.

Spanning tree is the protocol that makes redundancy usable. It builds one loop free tree across the switched domain by blocking the links it does not need, then unblocks one when the topology changes. Every variant, from the original 802.1D through RSTP and MST, is a different answer to the same two questions: which switch is in charge, and which ports are allowed to forward right now. Understanding those two answers is enough to predict what a real network will do, and the commands in this article let you read the truth off the devices instead of trusting the diagram.

At a Glance: STP, RSTP, and MST

STP (802.1D) RSTP (802.1w) MST (802.1s)
Tree count One for the whole network One for the whole network One per instance, many instances
Port roles Root, designated Root, designated, alternate, backup Same as RSTP, per instance
Port states Blocking, listening, learning, forwarding Discarding, learning, forwarding Same as RSTP, per instance
Convergence 30 to 50 seconds Under a second to a few seconds Same as RSTP, per instance
BPDU version 0 2 3, with an MST extension
Load sharing None, one topology None unless you run per VLAN variants Different roots per instance
Interoperability Baseline Falls back to STP on old neighbors Presents the region as one RSTP bridge
Typical use Legacy gear, lab setups Access and distribution layers Large networks with many VLANs

The loop that takes the network down

Two links between the same pair of switches is the simplest loop, and it needs no misconfiguration to exist. Someone adds a second uplink for redundancy, or a patch cable is left in a spare port during a maintenance window, and the topology becomes a cycle. The forwarding logic of an Ethernet switch does not know about cycles, so it does the only thing it was built to do: flood unknown and broadcast frames out of every port except the one they arrived on.

Three switches joined in a triangle, showing one broadcast frame circulating on every link A TRIANGLE IS A LOOP SW-A 1 Gbps ports SW-B flooding SW-C MAC churn What the storm costs Both uplinks saturate at line rate The MAC table relearns the same host CPU climbs on every switch in the loop New flows fail before the old ones stop Ethernet frames carry no hop limit, so a single broadcast keeps circling until a link is blocked or removed.

The failure is fast and it looks like a capacity problem at first. Uplinks run at 1 Gbps and show 1 Gbps of traffic, users report that everything is slow, and pings to the gateway drop rather than fail cleanly. If you go looking for a broadcast storm before you look for a loop, you will find one, but the broadcast is the symptom. The cause is a topology with more than one path between two points and nothing deciding which path is allowed to carry traffic.

Spanning tree solves this by turning the mesh into a tree. One switch becomes the root, every other switch finds exactly one path toward it, and any extra link is placed in a non forwarding state where it still receives protocol messages but carries no user traffic. The blocked link is not wasted: it is the spare tire, and the protocol can put it into service in seconds when the active path disappears. That is the entire bargain, and everything else in this article is detail about how the bargain is enforced.

Root election, path cost, and the tie break

The protocol runs on bridge protocol data units, BPDUs, which every switch sends out of every port at a fixed hello interval of 2 seconds. The BPDU carries the sender’s bridge ID, its cost to the root, and the sender’s port identifier. A switch that receives a BPDU with a better claim than its own adopts that claim and forwards it outward, so the whole network converges on one view of who is root and how far away it is.

The bridge ID is 8 bytes: a 2 byte priority and the 6 byte MAC address. Priority defaults to 32768 and moves in steps of 4096, so a value of 4096 beats every default switch on the network and a value of 0 beats everything. Election is simple: lowest bridge ID wins. That simplicity is also the trap, because a network where nobody set a priority elects whichever switch has the lowest MAC address, which is rarely the switch you want carrying the tree.

A core switch elected root with two distribution switches, one forwarding toward the root and one blocking ROOT ELECTION AND PORT ROLES SW-CORE-1 priority 4096, root SW-DIST-1 root port, cost 20000 SW-DIST-2 alternate, blocking link held in reserve Both distribution switches see the same root. Only one of them may forward toward it, so the other blocks.

Each non root switch then picks exactly one root port, the port with the lowest cost to the root. Path cost comes from the link speed, and there are two scales in use. The older short method from 802.1D gives 100 Mbps a cost of 19 and 1 Gbps a cost of 4, which is too coarse for modern speeds. The long method from 802.1t gives 1 Gbps a cost of 20000, 10 Gbps 2000, and 100 Gbps 200, so it keeps distinguishing links as speeds increase.

Link speed Short cost Long cost
10 Mbps 100 2000000
100 Mbps 19 200000
1 Gbps 4 20000
10 Gbps 2 2000
100 Gbps not defined 200

Cost accumulates along the path, and that is the number worth checking on a real switch. A distribution switch reached through one 1 Gbps uplink to the core carries a root path cost of 20000, through two hops it carries 40000, and the second uplink to the core loses on cost and blocks. When two paths have the same total cost, the tie breaks in a fixed order: lowest sender bridge ID, then lowest sender port priority, then lowest sender port number. Port priority defaults to 128 and moves in steps of 16, which is why interface numbering quietly decides which link survives in many unplanned networks.

Reading the result takes one command on a Cisco switch.

SW-DIST-1# show spanning-tree vlan 10

VLAN0010
  Spanning tree enabled protocol rstp
  Root ID    Priority    4096
             Address     001b.2c3d.4e5f
             Cost        20000
             Port        24 (GigabitEthernet1/0/24)
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec

  Bridge ID  Priority    32778  (priority 32768 sys-id-ext 10)
             Address     00a3.8f12.9c40

Interface           Role Sts Cost      Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Gi1/0/1             Desg FWD 20000     128.1    P2p
Gi1/0/24            Root FWD 20000     128.24   P2p
Gi1/0/48            Altn BLK 20000     128.48   P2p

Four values carry the whole story. Root ID Priority 4096 says the root is deliberate. Cost 20000 says this switch is one gigabit hop away. Gi1/0/24 Root FWD is the live path. Gi1/0/48 Altn BLK is the spare, ready and silent. If the root priority here read 32768 with a MAC address you cannot identify, the tree would be running on a default election and every design decision downstream would be accidental.

Classic STP: the timers set the pace

The original protocol converges by waiting, and the waiting is visible in the port states. A port starts in blocking, which forwards nothing. When the topology says it should forward, it moves to listening for 15 seconds, where it still forwards nothing but participates in the protocol. Then it moves to learning for another 15 seconds, where it builds its MAC table without forwarding user frames. Only then does it forward. Add the 20 second max age timer that expires before a switch believes a silent path is dead, and a classic STP network can spend 30 to 50 seconds with a segment down after a link failure.

The timers are not local settings that happen to match. Hello time, max age, and forward delay are advertised by the root in every BPDU and used by every switch in the tree, which is why a root bridge configured with unusual timers changes convergence for the entire network. The defaults of 2, 20, and 15 seconds are tuned for a diameter of 7 bridges, and stretching the diameter without revisiting them is how a network ends up with a max age that expires while a BPDU is still in flight.

One rule makes classic STP usable on access ports. A port that faces a host will never create a loop, because a host does not forward BPDUs, so it does not need to wait at all. Marking it as an edge port, spanning-tree portfast on Cisco and edge in Junos, skips the listening and learning phases and puts the port straight into forwarding. Get that wrong on an uplink and you have created a loop the protocol cannot see, which is exactly what BPDU guard exists to prevent later in this article.

Topology change notifications are the other half of classic convergence. When a port changes state, the switch sends a notification toward the root, the root sets a topology change flag in its BPDUs, and every switch shortens its MAC address aging from the default 300 seconds to 15 seconds so stale entries disappear quickly. That flush is why a loop or a flapping link produces a burst of unknown unicast traffic: the tables were emptied, so every destination becomes unknown and gets flooded until it is learned again.

RSTP: a handshake instead of a countdown

RSTP, standardized as 802.1w and later folded into 802.1D-2004 and 802.1Q, keeps the same tree and the same election but replaces the countdown with a negotiation. It also simplifies the vocabulary to three states, discarding, learning, and forwarding, and names four roles: root, designated, alternate, and backup. The alternate role is the important addition, because a port can now be held in a state that says “I am a ready replacement for the root port” rather than just “I am blocked”.

The RSTP proposal and agreement exchange that brings a new link into forwarding without waiting for timers PROPOSAL AND AGREEMENT ON A NEW LINK Link comes up port is discarding Send proposal better than neighbor Neighbor syncs other ports pause Agreement port forwards The exchange is a single round trip on a point to point link. No forward delay timer is involved, and an existing alternate port can take over the moment the root port goes silent. Max age = 3 × hello = 6 s, so a silent neighbor is dead in 6 seconds, not 20.

The handshake starts on a link that has just come up. Both ends begin in discarding and exchange BPDUs. The switch that believes it has the better path sends a proposal, the neighbor blocks its other ports long enough to guarantee a loop free step, and replies with an agreement. The first switch moves its port to forwarding, and the process repeats one hop further into the network. On a point to point link the whole exchange is a few milliseconds, so a direct link failure with an alternate port available is repaired faster than a ping timeout.

RSTP also changes what a badly behaved neighbor looks like. If a switch stops sending BPDUs, the neighbor treats the path as failed after three hello intervals, six seconds by default, instead of waiting out the 20 second max age. If a port is configured as an edge port and receives a BPDU anyway, RSTP knows immediately that the assumption was wrong, and that detection is what makes BPDU guard effective.

Vendors expose RSTP in different shapes. Cisco ships PVST+ and Rapid PVST+, which run a separate instance for every VLAN, and spanning-tree mode rapid-pvst is the usual migration step from the default. Those per VLAN instances are a Cisco extension, not part of 802.1w, and they are the reason a Cisco network with 400 active VLANs carries 400 separate trees and 400 sets of BPDUs on every trunk. Junos reaches the same convergence from the other direction, where set protocols rstp runs one tree for the whole switch and VLAN count does not change the protocol load, while Arista ships MSTP as the default mode with spanning-tree mode mstp.

SW-DIST-1# show spanning-tree summary
Switch is in rapid-pvst mode
Root bridge for: none
Configured Pathcost method used is long
Name                   Blocking Listening Learning Forwarding STP Active
---------------------- -------- --------- -------- ---------- ----------
VLAN0010                     2         0        0          6          8

The Configured Pathcost method line is the one people miss. A switch using the short method assigns 4 to a 1 Gbps link and 19 to a 100 Mbps link, while a switch using the long method assigns 20000 and 200000. Mixed methods across a network produce a tree that looks plausible and is wrong, so verify the method on every platform before comparing costs between vendors.

MST: many VLANs, a few trees

MST, standardized as 802.1s, answers the scaling problem that per VLAN trees create. Instead of one tree per VLAN, you group VLANs into a small number of instances and run one independent tree per instance. Two instances are usually enough for a real design: one for the VLANs that should prefer the left core, one for the VLANs that should prefer the right core, which gives you load sharing without 400 BPDU streams.

VLANs grouped into two MST instances plus the CIST instance, each with its own root and blocked port VLAN MAPPING TO INSTANCES VLAN 10 VLAN 20 VLAN 30 VLAN 40 VLAN 50 MSTI 1 root at SW-CORE-A one tree, one blocked port MSTI 2 root at SW-CORE-B different port blocked Instance 0, CIST unmapped VLANs, region view Each instance runs its own election and its own blocked ports, so VLAN 10 can take the left uplink while VLAN 30 takes the right one. BPDUs per trunk: one set per instance, not one set per VLAN.

An MST network is organized into regions. A region is a group of switches that agree on three things exactly: the configuration name, the revision number, and the mapping of VLANs to instances. All three are hashed into a configuration digest carried in the MST BPDU, and a switch that receives a digest it does not recognize treats the sender as being outside its region. Inside the region, every instance is an independent tree. Across regions, the whole region presents itself as a single virtual bridge running one common tree, the Common and Internal Spanning Tree, on instance 0.

The practical consequence is that a typo in the region name does not degrade gracefully. Two switches that should be in the same region end up in two regions, the boundary behaves like a single link between two RSTP bridges, and your carefully planned second instance stops spanning the links it was supposed to protect. Configure the mapping from a template, not by hand, and verify the digest on every switch after any change.

SW-CORE-A(config)# spanning-tree mode mst
SW-CORE-A(config)# spanning-tree mst configuration
SW-CORE-A(config-mst)# name CORE-1
SW-CORE-A(config-mst)# revision 1
SW-CORE-A(config-mst)# instance 1 vlan 10,20
SW-CORE-A(config-mst)# instance 2 vlan 30,40
SW-CORE-A(config-mst)# exit
SW-CORE-A(config)# spanning-tree mst 0 priority 4096
SW-CORE-A(config)# spanning-tree mst 1 root primary
SW-CORE-A(config)# spanning-tree mst 2 root secondary

Junos expresses the same thing in set form, and the region rules are identical.

set protocols mstp configuration-name CORE-1
set protocols mstp revision-level 1
set protocols mstp msti 1 vlan [10 20]
set protocols mstp msti 2 vlan [30 40]
set protocols rstp interface ge-0/0/1 edge

Reading back the mapping is the only way to be sure the region is intact, because show spanning-tree will happily print a tree that is not the one you designed.

SW-CORE-A# show spanning-tree mst configuration
Name      [CORE-1]
Revision  1     Instances configured 3

Instance  Vlans mapped
--------  ---------------------------------------------------------------------
0         1-9,11-19,21-29,31-39,41-4094
1         10,20
2         30,40
-------------------------------------------------------------------------------

Two details in that output are worth checking. The name and revision must match on every switch in the region, character for character. The instance 0 line shows every VLAN that was not explicitly mapped, which is the default landing zone rather than a place to forget production VLANs.

Audit the tree in twenty minutes

The tree is a running configuration, not a document, and it changes with every link event. Auditing it means comparing what the protocol believes right now against what the design intended, and the fastest way to do that is a fixed output shape you can diff between runs.

  1. Find the root of every instance and confirm it is deliberate.
  2. List the role and state of every port on every switch.
  3. Check for inconsistent ports, which the protocol flags but nobody reads.
  4. Verify edge ports and their guard settings.
  5. Save the output in a dated directory so the next audit has a baseline.
mkdir -p audit/2026-11-24
for sw in sw-core-1 sw-dist-1 sw-dist-2; do
  ssh "$sw" "show spanning-tree root" > "audit/2026-11-24/${sw}-root.txt"
  ssh "$sw" "show spanning-tree vlan 10 | begin Interface" > "audit/2026-11-24/${sw}-vlan10.txt"
done
grep -H "This bridge is the root" audit/2026-11-24/*-root.txt

That grep answers the first question for the whole fleet in one line per root. If it prints a switch you did not expect, or prints nothing at all, the election is running on MAC addresses and priorities you did not choose. Fix that before touching anything else, because every port role in the network is downstream of it.

Port roles come next, and the counts matter more than the individual lines. On a well built access layer, most ports read Desg FWD and a small number read Root FWD on the uplinks. A Root FWD port facing a workstation means something is wrong with the edge configuration. An Altn BLK port on a port that faces a server usually means the host is bridging two interfaces or the cabling loops back through a second switch, and either way that link is not the spare path anybody intended.

SW-ACC-1# show spanning-tree vlan 10 | begin Interface
Interface           Role Sts Cost      Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Gi1/0/1             Desg FWD 20000     128.1    P2p Edge
Gi1/0/2             Desg FWD 20000     128.2    P2p Edge
Gi1/0/24            Root FWD 20000     128.24   P2p
Gi1/0/47            Altn BLK 20000     128.47   P2p

The Type column is where edge ports announce themselves. P2p Edge on a port that faces a switch is a loop waiting for a BPDU filter, so scan that column specifically.

Inconsistent ports are the findings the protocol already made and nobody acted on, and show spanning-tree inconsistentports lists them. A port in the root inconsistent state received a superior BPDU on an interface protected by root guard, which means a downstream switch is trying to become root. A port in the loop inconsistent state stopped receiving BPDUs on a port that should have kept receiving them, which is the shape of a unidirectional link failure.

A worklist keeps the findings from turning into a survey that nobody finishes.

Finding Evidence Fix Owner
Root is an access switch grep prints an unexpected hostname Set priority 4096 on the core, 8192 on the standby Network
Two roots per instance show spanning-tree root differs between sites Align bridge priorities per instance Network
Edge port receives BPDUs Port error disabled, show interfaces status shows err-disabled Confirm the far end, then enable BPDU guard everywhere Network
Blocked port on a server link Altn BLK on a port that faces a host Replace the second path with a bundle Compute
Instance 0 carries production VLANs show spanning-tree mst configuration mapping Add the VLANs to an explicit instance Network
Short and long path costs mixed Configured Pathcost method differs per switch Standardize the method, then recheck the tree Network

Guard the edges and the core

Spanning tree assumes every switch plays by the rules, and the guards exist for the moments when one does not. BPDU guard protects edge ports: if a port marked as an edge receives a BPDU, the switch shuts it down instead of trusting it, which stops a user from plugging in a cheap switch and reshaping the tree. Root guard protects the core: if a port that should never lead toward the root receives a superior BPDU, the port goes to the root inconsistent state rather than accepting the claim and moving the root to the access layer. Loop guard protects the tree from silence: if a blocking port stops receiving BPDUs without going down, it stays blocking instead of moving to forwarding and closing a loop that the protocol can no longer see.

SW-ACC-1(config)# interface range GigabitEthernet1/0/1-20
SW-ACC-1(config-if-range)# spanning-tree portfast
SW-ACC-1(config-if-range)# spanning-tree bpduguard enable
SW-ACC-1(config-if-range)# exit
SW-ACC-1(config)# interface GigabitEthernet1/0/24
SW-ACC-1(config-if)# spanning-tree guard root
SW-ACC-1(config)# spanning-tree loopguard default

Newer IOS XE releases accept spanning-tree portfast edge for the same behavior, and the global form spanning-tree portfast bpduguard default applies the guard to every port that is configured as an edge. Verify the result rather than assuming it, because the interface level setting wins over the global default and a single leftover port is enough to leave a hole.

SW-ACC-1# show spanning-tree interface Gi1/0/12
Vlan                Role Sts Cost      Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
VLAN0010            Desg FWD 20000     128.12   P2p Edge

If the port is error disabled by BPDU guard, the interface status shows err-disabled and the log names the cause. Recovery is deliberate on most platforms: errdisable recovery cause bpduguard plus errdisable recovery interval 300 re-enables the port after five minutes, but only after you have found the device that was sending BPDUs, since the same device will trip it again.

Choose the variant, then verify it

The choice between the three is mostly a question of how many trees your network needs and how fast it must heal. A small lab with a handful of switches can run RSTP on a single instance and never think about regions. A campus with two cores and a few dozen VLANs wants RSTP or MST with two instances so both cores carry traffic. A large network with hundreds of VLANs needs MST, because per VLAN trees put a BPDU stream and a tree computation on every trunk and every switch, and the operational cost of that grows with VLAN count rather than with physical topology.

Whatever you choose, the tree is only as good as the audit that follows it. The first concrete step is to run show spanning-tree root on every switch today and compare the output against the switch you intended to be root. If the answer is not the core, set the priority and rerun the same command afterward. That single check catches more spanning tree problems than any diagram review, because it tells you which switch is actually in charge rather than which one the drawing says should be.

Frequently Asked Questions

What is the difference between STP, RSTP, and MSTP?
STP is the original IEEE 802.1D protocol that blocks redundant links to remove loops and takes around 30 to 50 seconds to converge. RSTP, from IEEE 802.1w, keeps the same tree but replaces timer based convergence with a proposal and agreement handshake between neighbors, so a failed link is repaired in under a second on point to point ports. MSTP, from IEEE 802.1s, carries many VLANs on a small number of independent trees called instances, so you can run two different roots for two groups of VLANs without paying for one tree per VLAN.
What is the root bridge in spanning tree?
The root bridge is the switch with the lowest bridge ID, which is an 8 byte value made of a 2 byte priority and the 6 byte MAC address. Every other bridge builds a single loop free path toward it. The default priority is 32768, so an unconfigured network elects the oldest or lowest MAC address as root, which is why production networks set a deliberate priority such as 4096 on the intended core switch.
Why does a blocked spanning tree port still receive BPDUs?
A blocked port stops forwarding user traffic, not protocol traffic. It keeps listening for bridge protocol data units so it can learn about a better path or detect that the current path has failed, and that is how it becomes a root or designated port within seconds of a change. Filtering BPDUs on a blocked link would remove the protocol's ability to heal the tree.
How long does spanning tree take to converge?
Classic STP takes about 30 seconds after a direct link failure because a port must pass through listening and learning, 15 seconds each, before forwarding, and about 50 seconds when the failure is detected indirectly through the 20 second max age timer. RSTP converges in under a second when an alternate port already exists, and a few seconds when the change has to propagate through the tree. Edge ports with PortFast or edge configuration skip the waiting entirely.
How many switches can a spanning tree support?
The protocol carries a hop count, and the traditional design guidance caps the diameter at 7 bridges so the classic timer math stays valid. That limit is about convergence time, not about a hard ceiling on switch count. Wide flat designs with dozens of switches in a chain are legal but slow to converge and hard to troubleshoot, which is why distribution layers and routed links exist.
How do I find a switching loop?
Look for three signals together: a broadcast or unknown unicast rate pinned near line rate on several ports at once, the same MAC address learned on multiple ports, and the switch CPU elevated by the flooding. A blocked port that unexpectedly moves to forwarding, or a port that receives BPDUs on an edge interface, points at the same cause. Compare the current port roles against the last documented baseline and fix the link that should be blocking.

Stop reaching for a spreadsheet

Obelinf keeps every subnet, device, circuit, and rack in one live source of truth, with audit logs and a topology view. Free for personal use.

Related Articles