Cisco · CCNA

Spanning Tree Protocol Explained — Root Bridge, Port Roles, RSTP and Config

By CertSharp Team~15 min readLast updated

Spanning tree protocol (STP) stops Layer 2 switching loops in networks with redundant links. Switches exchange BPDUs, elect one root bridge with the lowest bridge ID, and then keep only the best path from every switch to that root. All other redundant ports are blocked until a failure needs them. Cisco runs it per VLAN as PVST+ or Rapid PVST+.

Quick Facts

  • Layer: Layer 2 (data link). Switches send BPDUs to the multicast MAC 0180.C200.0000.
  • Election order: root bridge by lowest bridge ID; root port by lowest root path cost; designated port per segment by lowest root path cost.
  • Defaults: bridge priority 32768, hello 2 s, forward delay 15 s, max age 20 s.
  • Cisco default mode: PVST+ on older Catalyst IOS; Rapid PVST+ is the default on current IOS XE Catalyst 9000 (check your platform).
  • Cost (short method): 10 Mb/s = 100, 100 Mb/s = 19, 1 Gb/s = 4, 10 Gb/s = 2.
  • Exam relevance: CCNA 200-301 covers STP concepts in the Network Access area and Network+ N10-009 covers it as a switching feature. Check the official topic lists, linked in Sources.

Redundant links are good design: if one cable or switch fails, another path keeps the network up. At Layer 2 they are also dangerous, because Ethernet has no hop count to stop a frame from circulating forever. Spanning tree protocol is the mechanism that lets you have redundant links without the loops. It is one of the most tested switching topics on the Cisco CCNA 200-301, and it is the topic where candidates lose points by memorizing terms instead of understanding the elections. This guide walks through the logic with a worked example you can reproduce, then covers the versions, the protection features and the configuration.

Why do switched networks need spanning tree?

A switch forwards a broadcast, a multicast and any unknown unicast frame out of every port except the one it arrived on. Connect three switches in a triangle and a single broadcast leaves switch A in two directions, is flooded onward by B and C, and arrives back at A from the other side, again and again. Three problems follow:

  • Broadcast storm. Looping frames multiply until links and CPUs are saturated. The network can become unusable within seconds.
  • MAC table instability. The same source MAC address appears on different ports as copies arrive from several directions, so the switch keeps re-learning it.
  • Multiple frame copies. Hosts receive duplicate frames, which can break some applications.

Layer 3 does not suffer this: an IP packet has a TTL that is decremented at each router, so a looping packet eventually dies (see our OSI model guide for the layer context). Ethernet frames have no such field, so STP logically removes the loop instead. It does this without removing the cables: redundant ports are simply blocked until needed.

What are BPDUs and the bridge ID?

Switches speak STP using Bridge Protocol Data Units (BPDUs), sent to the multicast MAC address 0180.C200.0000. Every 2 seconds (the hello time) the root bridge sends a configuration BPDU and other switches relay it. A BPDU carries the root bridge ID, the sending bridge ID, the cost to the root and the sending port ID, which is all a switch needs to compare candidates.

The bridge ID is eight bytes: a 16-bit bridge priority field followed by the 48-bit switch MAC address. On Cisco switches running per-VLAN spanning tree, the priority field is split into a 4-bit priority and a 12-bit extended system ID that holds the VLAN number. That is why the configured priority is always a multiple of 4096 and why the value you see is 32768 plus the VLAN (32769 for VLAN 1, 32778 for VLAN 10).

Part of the bridge IDSizeDefaultNotes
Priority4 bits32768Configure in steps of 4096 (0, 4096, 8192 and so on)
Extended system ID (VLAN)12 bitsVLAN numberLets one MAC address serve every VLAN in PVST+
MAC address48 bitsBurned-in switch MACOnly used as the tie-breaker

How is the root bridge elected?

Every switch begins by assuming it is the root and advertising its own bridge ID. When a switch receives a BPDU with a lower root bridge ID, it stops claiming the role and relays the better one. After a few BPDU exchanges the whole network agrees: the switch with the lowest bridge ID is the root bridge. Compare priority first, then MAC address.

This has a practical consequence. With all switches on default priority, the root is whichever has the lowest MAC address, which tends to be the oldest switch, perhaps a forgotten access switch at the far edge. Traffic then takes a poor path through it. The professional habit is to choose the root deliberately, typically a distribution or core switch, by lowering its priority, and to set a second switch as the backup root.

How are root ports and designated ports elected?

After the root bridge exists, each remaining switch decides what role every port plays. There are three main roles in classic STP:

  • Root port (RP): on every non-root switch, the one port with the best path toward the root bridge. The root bridge has none.
  • Designated port (DP): on every network segment, the one port that forwards traffic toward the segment on behalf of that segment. Every port on the root bridge is a designated port.
  • Blocking (non-designated) port: every other port. It does not forward user traffic.

Root port election compares, in order: (1) lowest root path cost; (2) lowest sender bridge ID; (3) lowest sender port priority (default 128); (4) lowest sender port ID. The designated port election on each segment uses the same logic: the port on the switch advertising the lowest root path cost wins; a tie goes to the lower bridge ID of the switch on that segment.

Root path cost is the sum of the port costs along the path, counted as the BPDU is received (each switch adds the cost of the port it received it on). Default costs for the short method:

Link speedSTP cost (802.1D-1998 short)Long method (802.1t)
10 Mb/s1002,000,000
100 Mb/s19200,000
1 Gb/s420,000
10 Gb/s22,000

Cisco switches use the short method by default in PVST+ and the long method is optional (spanning-tree pathcost method long). All switches in a domain should agree, or paths can be chosen unexpectedly.

Worked example: electing roles in a three-switch triangle

Three switches are connected in a triangle, all links Gigabit Ethernet (cost 4), all in VLAN 1 with default priorities. The MAC addresses decide the root:

SwitchPriority (VLAN 1)MAC addressBridge ID
SW1327690000.0000.000132769.0000.0000.0001
SW2327690000.0000.000232769.0000.0000.0002
SW3327690000.0000.000332769.0000.0000.0003

Links: SW1 Gi0/1 to SW2 Gi0/1, SW1 Gi0/2 to SW3 Gi0/1, and SW2 Gi0/2 to SW3 Gi0/2.

  1. Root bridge. All priorities tie, so the lowest MAC wins: SW1. All SW1 ports become designated ports.
  2. Root ports. SW2 can reach SW1 directly through Gi0/1 (cost 4) or through SW3 (4 + 4 = 8). Gi0/1 wins, so it is SW2's root port. SW3 likewise picks its Gi0/1.
  3. Designated port on the SW2 to SW3 segment. Both ends advertise a root path cost of 4. Tie. The lower bridge ID wins, which is SW2, so SW2 Gi0/2 is designated (forwarding).
  4. Blocked port. SW3 Gi0/2 is neither root nor designated, so it blocks.
SwitchPortRoleState
SW1Gi0/1DesignatedForwarding
SW1Gi0/2DesignatedForwarding
SW2Gi0/1RootForwarding
SW2Gi0/2DesignatedForwarding
SW3Gi0/1RootForwarding
SW3Gi0/2Alternate / blockingBlocking (STP) or Discarding (RSTP)

The loop is broken at exactly one point, SW3 Gi0/2. If the SW1 to SW3 link fails, SW3 unblocks Gi0/2 and reaches the root through SW2. A good exam habit is to draw a topology like this and mark root path costs on every port before answering; most STP questions are this procedure with different numbers.

Practice this for the CCNA

Try the free Cisco CCNA 200-301 practice exam: 30 questions per session in practice mode, no signup needed. The full 500-question bank with exam mode is on the pricing page.

What are the STP port states?

In classic 802.1D, a port moves through states with timers controlling progress:

StateReceives BPDUsLearns MACsForwards framesTypical duration
DisabledNoNoNoAdministratively down
BlockingYesNoNoUp to max age (20 s) before a change
ListeningYesNoNoForward delay, 15 s
LearningYesYesNoForward delay, 15 s
ForwardingYesYesYesUntil a topology change

The timers and their defaults are hello 2 seconds, forward delay 15 seconds and max age 20 seconds. When a blocked port stops hearing BPDUs for max age, it starts to transition; add the two forward-delay periods and you get the classic figure of 30 to 50 seconds of outage. That delay is the main reason RSTP was created.

STP vs RSTP vs PVST+ vs Rapid PVST+: what is the difference?

VersionStandardInstancesConvergenceNotes
STPIEEE 802.1D (original)One for the whole network (CST)30 to 50 sTimer-based; port states Blocking, Listening, Learning, Forwarding
PVST+Cisco proprietary extensionOne per VLAN30 to 50 sLets you balance load by choosing a different root per VLAN
RSTPIEEE 802.1w, folded into 802.1D-2004One for the whole networkAbout 1 s or less on point-to-point linksStates Discarding, Learning, Forwarding; roles add Alternate and Backup
Rapid PVST+Cisco proprietary, RSTP per VLANOne per VLANAbout 1 s or lessCommon modern default choice on Cisco campus networks
MSTPIEEE 802.1s, part of 802.1QMaps groups of VLANs to a few instancesRapidScales better than per-VLAN when there are hundreds of VLANs

Key RSTP differences to remember. First, the Blocking, Listening and Disabled states collapse into Discarding. Second, RSTP adds two roles: Alternate (a backup path to the root through another switch, ready to replace the root port instantly) and Backup (a redundant port on the same segment as a designated port). Third, RSTP uses a proposal and agreement handshake on point-to-point links and treats edge ports (PortFast) as immediately forwarding. Fourth, every switch generates BPDUs, not just relays them, and a neighbor is declared lost after missing three hellos (6 seconds) instead of waiting for max age.

Cisco labs and the CCNA tend to focus on Rapid PVST+. A frequent exam pattern is to give a set of outputs and ask which port is the root port or which port is alternate, using exactly the rules above. If you are unsure of the version behavior, note that the Cisco documentation for your specific platform is the final word on defaults.

What are PortFast, BPDU guard and root guard?

These features harden spanning tree against the most common real-world failures:

FeatureWhereWhat it does
PortFastAccess ports facing hostsSkips Listening and Learning so the port forwards at once. Never use it toward another switch.
BPDU guardPortFast portsPuts the port in err-disabled if a BPDU arrives. Stops accidental or rogue switches.
BPDU filterSpecific portsStops sending or receiving BPDUs. Dangerous if misused because it can hide a loop.
Root guardPorts facing switches that must never become rootBlocks the port (root-inconsistent) if a superior BPDU arrives. Recovers when BPDUs stop.
Loop guardNon-designated portsPrevents a blocking port from becoming designated if BPDUs stop arriving, for example because of a unidirectional link.
UDLDFiber linksDetects unidirectional links so STP does not assume the link is healthy.

The classic exam pairing is PortFast plus BPDU guard on access ports, and root guard on ports toward devices you do not control. They are different: BPDU guard shuts a port down on any BPDU, root guard only reacts to a superior BPDU.

How do I configure spanning tree on Cisco switches?

A sensible baseline: Rapid PVST+, a deliberate root, PortFast and BPDU guard on access ports.

! On every switch
SW1(config)# spanning-tree mode rapid-pvst

! On the intended root (distribution/core) for VLANs 10 and 20
SW1(config)# spanning-tree vlan 10,20 root primary

! On the intended backup root
SW2(config)# spanning-tree vlan 10,20 root secondary

! Or set the priority explicitly instead of root primary
SW1(config)# spanning-tree vlan 10 priority 4096

! On an access port facing a PC
SW3(config)# interface GigabitEthernet0/5
SW3(config-if)# switchport mode access
SW3(config-if)# switchport access vlan 10
SW3(config-if)# spanning-tree portfast
SW3(config-if)# spanning-tree bpduguard enable

! Or enable globally on all PortFast ports
SW3(config)# spanning-tree portfast default
SW3(config)# spanning-tree portfast bpduguard default

! On a port facing a switch that must not become root
SW1(config)# interface GigabitEthernet0/24
SW1(config-if)# spanning-tree guard root

! Influence which port becomes root port (lower cost = preferred)
SW2(config)# interface GigabitEthernet0/1
SW2(config-if)# spanning-tree vlan 10 cost 2

root primary lowers the priority only far enough to win at the moment you enter it (normally to 24576, or 4096 below the current root), whereas an explicit priority value stays fixed. Both are valid answers on an exam; know the difference. Pair this layer with a gateway redundancy design: the root bridge for a VLAN should normally be the same device as the Active gateway in HSRP, so frames do not take a detour.

How do I read show spanning-tree output?

SW2# show spanning-tree vlan 10

VLAN0010
  Spanning tree enabled protocol rstp
  Root ID    Priority    4106
             Address     0000.0000.0001
             Cost        4
             Port        1 (GigabitEthernet0/1)
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec

  Bridge ID  Priority    32778  (priority 32768 sys-id-ext 10)
             Address     0000.0000.0002
             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.1    P2p
Gi0/2               Desg FWD 4         128.2    P2p

Read the top block as the root and the second block as this switch. If the two addresses match, the message "This bridge is the root" appears and you are looking at the root. Here the root has priority 4106 (4096 + VLAN 10), this switch is 32778, so it is not the root; its root port is Gi0/1 with cost 4. The table lists each port's role (Root, Desg, Altn, Back), status (FWD, BLK, LRN or DIS in classic STP; FWD, LRN or BLK shown for RSTP discarding) and link type (P2p or Shr). Other quick commands: show spanning-tree summary, show spanning-tree root, show spanning-tree interface gigabitethernet0/1 detail and show spanning-tree inconsistentports. The values in this block are illustrative and come from a different VLAN 10 topology than the worked example above, where the root was deliberately set to priority 4096.

How does EtherChannel interact with spanning tree?

EtherChannel (port channel) bundles up to eight active physical links into one logical interface. Spanning tree then sees the bundle as one port, so it does not block individual members, and the combined bandwidth gives a lower STP cost than a single link. The main points to remember:

  • STP runs on the port-channel interface, not on each member; member ports only forward user traffic when the bundle is up.
  • Two parallel links without EtherChannel are a loop, and STP will block one of them. With EtherChannel, both carry traffic and STP sees one link.
  • Configuration mismatches (speed, duplex, trunk mode or allowed VLANs) can suspend a member port and surprise you.
  • If EtherChannel negotiation fails and one side bundles while the other does not, you can create a temporary loop; STP and the EtherChannel misconfiguration guard exist to limit the damage.

How do I troubleshoot spanning tree problems?

  1. Unexpected root bridge. Run show spanning-tree root on a few switches. If the root is an access switch, lower the priority on the intended root. Use root guard on edge-facing ports to prevent a rogue switch from taking over.
  2. Suboptimal path. Compare root path costs and consider changing port cost (spanning-tree vlan N cost X) or the root per VLAN for load balancing.
  3. Ports err-disabled. Check show interfaces status err-disabled; a BPDU guard trigger means a switch or hub was connected to an access port.
  4. Mismatched modes. Rapid PVST+ and PVST+ interoperate by falling back to the slower behavior on the shared link, so convergence is slow where they meet. Standardize on one mode.
  5. Broadcast storm symptoms. Very high interface utilization, flapping MAC table entries, and a switch CPU at near 100 percent. Find the loop by disconnecting links or looking for a recently changed STP configuration, a unidirectional link, or BPDU filter misuse.
  6. Frequent topology changes. show spanning-tree detail shows topology change counts and the port that caused them. A flapping host port without PortFast is a common cause.

What are the exam traps for CCNA and Network+?

The CCNA exam guide explains the blueprint. Exact objective wording changes between exam versions, so check the official Cisco and CompTIA pages linked in the sources. In practice, expect port role, port state and root election questions on the CCNA, and a simpler "what does STP do, and which feature protects an access port" style on CompTIA Network+ N10-009. The decision of which to take first is in Network+ vs CCNA.

  • Lowest wins, everywhere. Lowest bridge ID, lowest cost, lowest port ID. Candidates sometimes pick the highest MAC by mistake.
  • Priority before MAC. A switch with a better priority beats one with a lower MAC.
  • The VLAN is added to the priority. Default 32768 is displayed as 32769 for VLAN 1 in PVST+.
  • Priority steps of 4096. A value like 5000 is rejected.
  • Root ports and designated ports forward. Only the leftover ports block, and a port on the root bridge is never blocked.
  • Cost accumulates. The root path cost is the sum along the path, not the cost of a single link.
  • PortFast is for edge ports only. It is not a convergence fix for trunks.
  • BPDU guard versus root guard. BPDU guard disables the port; root guard only blocks it while superior BPDUs arrive.
  • STP versus RSTP states. RSTP has no Blocking or Listening; it uses Discarding.

Keep the key numbers on a single sheet: our CCNA cheat sheet collects them, and the subnetting guide covers the other big calculation topic. For routing-protocol context, see OSPF and EIGRP; spanning tree is the Layer 2 equivalent of choosing a best path.

Check yourself: three quick STP questions

Check 1. Switch A has priority 32768 and MAC 0000.0000.00AA. Switch B has priority 4096 and MAC 0000.0000.00FF. Which is the root bridge?

Switch B. Priority is compared first and lowest wins, so 4096 beats 32768 regardless of MAC address. MAC only breaks priority ties.

Check 2. What does a non-root switch use to choose its root port?

The lowest total path cost to the root bridge. Ties go to the lowest sender bridge ID, then lowest sender port priority, then lowest sender port ID.

Check 3. A user plugs a small switch into a PortFast port that has BPDU guard enabled. What happens?

The port receives a BPDU, BPDU guard moves it to the err-disabled state, and the port goes down until it is recovered manually or by errdisable recovery.

Spanning tree protocol practice questions with answers

For more, see CCNA practice questions or the CCNA practice exam.

1. What is the default bridge priority on a Cisco switch, and how does the VLAN affect the value in PVST+?

The default is 32768. In PVST+ the VLAN ID is added as the extended system ID, so VLAN 10 has priority 32778 and VLAN 1 has 32769. Priority can only be configured in multiples of 4096.

2. Which two values make up the bridge ID, and which one is compared first?

Bridge priority (plus extended system ID) and the switch MAC address. Priority is compared first; the MAC address is only the tie-breaker.

3. What is the default STP path cost for a Gigabit Ethernet link and for Fast Ethernet using the short (802.1D-1998) method?

Gigabit Ethernet is 4 and Fast Ethernet is 19. Ethernet 10 Mb/s is 100 and 10 Gigabit Ethernet is 2. Remember that lower cost means higher speed and therefore a preferred path.

4. In classic 802.1D STP, which port states does a port pass through before it forwards, and how long does it normally take?

Blocking, Listening, Learning, then Forwarding. With default timers a port waits 15 seconds in Listening and 15 seconds in Learning (the forward delay), so convergence after a direct topology change is about 30 seconds, and up to about 50 seconds when it must also wait out max age (20 seconds).

5. Which RSTP port role replaces the idea of a port that is blocking because it offers an alternative path to the root bridge?

Alternate. A Backup port is different: it is a redundant path to a segment where the switch already has a designated port, which only happens on shared segments or when two ports of one switch connect to each other.

6. Which command makes a switch the root bridge for VLAN 10 by lowering its priority automatically, and what priority does it normally set?

spanning-tree vlan 10 root primary, which normally sets the priority to 24576 (or 4096 lower than the current root if that is not enough). root secondary sets 28672. Setting the value yourself with spanning-tree vlan 10 priority 4096 also works and is more predictable.

7. An access port connected to a PC takes about 30 seconds to start passing traffic after the cable is plugged in, and the PC times out on DHCP. What is the fix?

Enable PortFast on the access port (spanning-tree portfast) so it goes straight to forwarding, and add BPDU guard to protect it. Changing the root bridge or the hello timer would not remove the listening and learning delay on that port.

8. A switch port is in the root-guard-inconsistent state. What caused it?

The port received a superior BPDU, one claiming a better root bridge than the current one, on a port where root guard is enabled. Root guard blocks the port instead of letting that switch become root. The port recovers automatically when the superior BPDUs stop.

Frequently asked questions

What is spanning tree protocol (STP) in networking?

Spanning tree protocol is a Layer 2 protocol, originally standardized as IEEE 802.1D, that prevents switching loops in networks with redundant links. Switches exchange BPDUs, elect one root bridge, and then block the redundant ports so that exactly one loop-free path exists between any two devices. If an active link fails, a blocked port is brought into service.

How is the STP root bridge elected?

Every switch starts by claiming to be the root. The switch with the lowest bridge ID wins, where the bridge ID is the bridge priority (default 32768, plus the VLAN number in PVST+) followed by the switch MAC address. Lowest priority wins; if priorities tie, the lowest MAC address wins. Because default priorities are equal, the oldest or lowest-MAC switch often becomes root by accident, so you should set it deliberately.

How is the root port elected?

Each non-root switch selects exactly one root port: the port with the lowest total path cost to the root bridge. Ties are broken by the lowest sender bridge ID, then the lowest sender port priority, then the lowest sender port number. The root bridge itself has no root port.

What is the difference between STP and RSTP?

Classic STP (802.1D) uses timers: ports pass through Blocking, Listening and Learning before Forwarding, so recovery takes roughly 30 to 50 seconds. Rapid Spanning Tree (RSTP, IEEE 802.1w, now part of 802.1D-2004) negotiates with a proposal and agreement handshake and recovers in about a second or less on point-to-point links. RSTP has three states (Discarding, Learning, Forwarding) and adds Alternate and Backup port roles.

What is PortFast and why use it with BPDU guard?

PortFast moves an access port straight to forwarding, skipping the listening and learning delay, which stops hosts from timing out while DHCP waits. Because a PortFast port should never connect to another switch, BPDU guard shuts the port down (err-disabled) if a BPDU arrives, which protects the topology from accidental loops and rogue switches.

Why is a port blocking or discarding in spanning tree?

Because it is not the best path. After the root bridge, root ports and designated ports are chosen, every remaining port that would create a loop is placed in the blocking state in classic STP or the alternate or backup role (discarding state) in RSTP. A blocking port still receives BPDUs, but it does not forward user traffic and does not learn MAC addresses.

Do I still need spanning tree if I use EtherChannel?

Yes. EtherChannel bundles several physical links into one logical link, so spanning tree treats the bundle as a single port and does not block individual members. You still need STP for the rest of the topology and as a safety net against misconfiguration. STP cost on a port-channel is based on the bundle bandwidth in many implementations, which can change your root port choices.

How we wrote and checked this

CertSharp is a practice-exam provider, and we sell the CCNA and Network+ practice questions linked in this guide. We wrote this article from Cisco's Rapid Spanning Tree documentation and the IEEE 802.1 standards, linked in Sources. Bridge IDs, path costs, the three-switch election and the timers were worked through by hand and re-checked, and the show spanning-tree output is illustrative, not captured from production equipment. Last reviewed October 2026. Defaults vary by platform and release, so confirm on your own switch.

Sources and further reading

Spanning tree is defined by the IEEE 802.1D and 802.1Q standards; PVST+ and Rapid PVST+ are Cisco implementations, and defaults vary by switch platform and software release, so confirm with show spanning-tree on your device.

Practice spanning tree and the rest of the CCNA

30 free questions per session in practice mode, no signup and no credit card. The full 500-question CCNA bank with exam mode is $11.99 lifetime, or $9.99/month Pro unlocks every CertSharp certification.