Three switches cabled into a triangle have exactly one Layer 2 loop. Spanning Tree Protocol blocks one port to break it, and which port it blocks is decided by three numbers: the bridge priority, the path cost to the root, and the MAC address on a tie. Set those numbers deliberately and the topology is predictable. Leave them at the defaults and the switches decide for you, usually not the way you want.
This guide configures Spanning Tree Protocol in Rapid PVST+ mode on a three-switch triangle, forces a chosen root bridge, and reads the resulting port roles and states from real output. The blocked port is the whole point: it is the loop being broken, held in reserve until a link fails. It then adds root guard and loop guard on the switch-to-switch links. Every output here came from IOSvL2 switches running Cisco IOS 15.2 in GNS3, and the guard tests were run in November 2026.
Why Spanning Tree exists
A switched network wants redundant links for resilience. Layer 2 has no TTL to kill a looping frame, so a single physical loop turns redundancy into a failure: broadcasts circulate forever (a broadcast storm), the same source MAC arrives on two ports so the MAC address table flaps, and frames are duplicated. STP keeps the redundant cabling but logically blocks enough ports to leave exactly one active path between any two points.
The lab is the smallest topology that produces a loop: three switches, each connected to the other two.

SW1 is forced to be the root. The SW1-SW2 and SW1-SW3 links forward; the SW2-SW3 link is the one STP blocks, and it blocks it on SW3. The same triangle was built on three IOSvL2 switches in GNS3, which produced every capture below:

With the cabling in place and a loop present, the configuration starts by choosing which switch should be the root.
Step 1: Set the mode and elect the root bridge
The root bridge is the reference point the whole tree is measured from, so it should be a deliberate choice, not an accident of MAC addresses. The election is won by the lowest Bridge ID. A Bridge ID is 8 bytes: a 2-byte priority followed by the switch’s 6-byte MAC. With per-VLAN spanning tree the priority field is a 4-bit base priority plus the 12-bit VLAN ID, so the default 32768 shows as 32769 for VLAN 1. Priority is configurable only in steps of 4096.
Set the mode to Rapid PVST+ on all three switches, then give SW1 the lowest priority so it wins:
configure terminal
spanning-tree mode rapid-pvst
spanning-tree vlan 1 priority 4096
end
SW2 takes 8192 (the backup root), and SW3 keeps the default 32768. The root primary and root secondary keywords are a shortcut that picks the priority for you (24576 and 28672), but setting an explicit 4096 and 8192 makes the intent and the math obvious. Run the mode command on every switch; a switch left in the default per-VLAN mode still interoperates, but the topology should be one mode throughout.
Step 2: Verify the root bridge
On SW1, confirm it actually won. show spanning-tree vlan 1 states it plainly when a switch is the root:
show spanning-tree vlan 1
SW1 reports itself as the root for VLAN 1:

The number that matters is the priority: 4097, which is the configured 4096 plus the VLAN-1 system ID extension. The Root ID and the Bridge ID are identical, and the line “This bridge is the root” confirms it. Every port on the root bridge is a designated port in the forwarding state (Desg FWD), because the root never blocks. The protocol line reads rstp, which is what Rapid PVST+ runs per VLAN.
Step 3: Read the non-root switch and find the blocked port
The interesting output is on SW3, the switch with the highest priority. It has two paths to the root: the direct SW1-SW3 link at a cost of 4, and the indirect path through SW2 at a cost of 8. It picks the lower cost, so its root port is Gi0/0 toward SW1.
show spanning-tree vlan 1
show spanning-tree root
SW3 shows the root port and the one port STP is holding down:

Gi0/0 is the root port, forwarding (Root FWD). Gi0/1, toward SW2, is the alternate port in the blocking state (Altn BLK). That is the loop being broken. The decision on the SW2-SW3 segment came down to a Bridge ID comparison: both switches reach the root at a cost of 4, so the tie goes to the lower Bridge ID, and SW2 at priority 8192 beats SW3 at 32768. SW2 becomes the designated port for that segment, which leaves SW3’s port as the alternate. show spanning-tree root summarises it in one line: root ID 4097, root cost 4, root port Gi0/0.
Step 4: Port roles, states, and the mode
Every port lands in one role and one state. The roles answer “what is this port for”, the states answer “is it passing traffic”. On the root bridge all ports are designated; on a non-root switch there is exactly one root port and the rest are designated or alternate.
| Port role | Meaning |
|---|---|
| Root port (RP) | Lowest-cost path to the root. One per non-root switch. Always forwarding. |
| Designated port (DP) | The forwarding port for a segment. One per segment. The root has all designated ports. |
| Alternate port | A blocked backup path to the root. Takes over if the root port fails. |
The states differ between classic and rapid STP. The original 802.1D walks a port through four states over roughly 30 to 50 seconds; RSTP, which Rapid PVST+ is built on, collapses them to three and converges in seconds:
| 802.1D (classic STP) | RSTP / Rapid PVST+ | Passing traffic? |
|---|---|---|
| Blocking | Discarding | No |
| Listening | Discarding | No |
| Learning | Learning | No (learns MACs) |
| Forwarding | Forwarding | Yes |
Confirm the mode and the cost method with show spanning-tree summary:
show spanning-tree summary
The mode and the cost method are near the top of the output:

Two lines matter here. “Switch is in rapid-pvst mode” confirms the protocol, and “Configured Pathcost method used is short” sets the cost values: 10 Mbps = 100, 100 Mbps = 19, 1 Gbps = 4, 10 Gbps = 2. Those are the numbers that decided SW3’s root port. Because this is per-VLAN spanning tree, every VLAN that crosses an 802.1Q trunk runs its own instance, so a trunk can forward VLAN 10 on a port while blocking VLAN 20 on the same port.
Step 5: PortFast and BPDU Guard on host ports
A port connected to a single host, a server, or an access point should not wait through the spanning-tree states on every link-up. PortFast moves an access port straight to forwarding, skipping the transition delay every other port takes, so a host gets a usable link immediately. Apply it only to host-facing access ports, never to a switch-to-switch link:
interface GigabitEthernet0/3
switchport mode access
spanning-tree portfast
spanning-tree bpduguard enable
BPDU Guard is the safety net that makes PortFast safe. A host port should never receive a BPDU. If one arrives, something that speaks spanning tree (a switch) was plugged into a port that assumes a host, which is exactly how an accidental loop forms. BPDU Guard err-disables the port the moment a BPDU lands, shutting the threat down instead of letting it forward. The two are configured together on every access port that faces a user. To verify the global defaults instead of per-port settings, show spanning-tree summary lists the PortFast and BPDU Guard default state.
Step 6: Root guard and loop guard on switch links
BPDU Guard protects ports that face hosts. Links between switches need two different protections, because on those ports BPDUs are expected and the danger is the wrong BPDUs, or none at all. Root guard keeps the root bridge where you put it, and loop guard stops a blocked port from opening up when it stops hearing BPDUs. We tested both on our triangle, with SW1 as the root at priority 4096, SW2 at 8192 and SW3 left at the default.
Root guard: keep the root where you put it
Root guard goes on designated ports that face switches which must never become root, such as access switches or a switch owned by another team. SW1’s Gi0/1 faces SW3, so we put it there.
interface GigabitEthernet0/1
spanning-tree guard root
To test it, we gave SW3 a priority that beats SW1’s, so its BPDUs become superior. On SW3:
spanning-tree vlan 1 priority 0
SW1 refused those BPDUs on the guarded port. Check its log:
show logging | include ROOTGUARD
Each block message names the port and the VLAN.
*Nov 30 13:29:41.814: %SPANTREE-2-ROOTGUARD_CONFIG_CHANGE: Root guard enabled on port GigabitEthernet0/1.
*Nov 30 13:29:47.727: %SPANTREE-2-ROOTGUARD_BLOCK: Root guard blocking port GigabitEthernet0/1 on VLAN0001.
SW1 now treats the port as root-inconsistent, and show spanning-tree inconsistentports lists it that way.
Name Interface Inconsistency
-------------------- ------------------------ ------------------
VLAN0001 GigabitEthernet0/1 Root Inconsistent
Number of inconsistent ports (segments) in the system : 1
So far so good. Our surprise came from SW1’s own view of the root.
show spanning-tree vlan 1
SW1 is no longer the root bridge. The root is SW3’s MAC address, reached through Gi0/0 toward SW2 at a cost of 8, and Gi0/1 shows the guard’s block as BKN with a ROOT_Inc flag (output trimmed).
Root ID Priority 1
Address 0cef.aa12.0000
Cost 8
Port 1 (GigabitEthernet0/0)
...
Interface Role Sts Cost Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Gi0/0 Root FWD 4 128.1 P2p
Gi0/1 Desg BKN*4 128.2 P2p *ROOT_Inc
Root guard only protects the port it is configured on. SW3’s superior BPDUs still reached SW2 on the other side of the triangle, SW2 had no guard, and SW2 passed SW3’s claim on to SW1. To keep a switch from ever becoming root, put root guard on every designated port that faces it, which here means SW2’s Gi0/1 as well, or simply never give the wrong switch a low priority. When SW3’s priority went back to the default with no spanning-tree vlan 1 priority 0, SW1 logged %SPANTREE-2-ROOTGUARD_UNBLOCK and Gi0/1 returned to Desg FWD with nobody touching it.
Loop guard: don’t forward when BPDUs stop
An alternate port stays blocked because it keeps receiving BPDUs from the designated port at the other end. If those BPDUs stop while the link stays up, as on a unidirectional fiber link or a misbehaving switch, the port decides there’s no better path on that segment, becomes designated and starts forwarding. That’s a loop. We reproduced it by filtering BPDUs on SW2’s Gi0/1, which stops SW2 from sending them to SW3. Never do this on a production switch link. On SW2:
interface GigabitEthernet0/1
spanning-tree bpdufilter enable
Twenty seconds later SW3’s blocked port had moved on.
show spanning-tree vlan 1 | begin Interface
Gi0/1 was Altn BLK before the filter. Now it reads designated and learning, one step from forwarding, with both ends of the SW2 to SW3 link designated.
Interface Role Sts Cost Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Gi0/0 Root FWD 4 128.1 P2p
Gi0/1 Desg LRN 4 128.2 P2p
With the filter removed (no spanning-tree bpdufilter enable on SW2), the port went back to Altn BLK. Loop guard belongs on root and alternate ports, the ones that are supposed to receive BPDUs, so we enabled it on SW3’s Gi0/1.
interface GigabitEthernet0/1
spanning-tree guard loop
Our same filter test now produced a block instead of a loop.
show logging | include LOOPGUARD
Loop guard logged the block and put the port in a loop-inconsistent state.
*Nov 30 13:32:06.199: %SPANTREE-2-LOOPGUARD_BLOCK: Loop guard blocking port GigabitEthernet0/1 on VLAN0001.
SW3’s port table marks it the same way root guard did, with BKN and a LOOP_Inc flag.
Interface Role Sts Cost Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Gi0/0 Root FWD 4 128.1 P2p
Gi0/1 Desg BKN*4 128.2 P2p *LOOP_Inc
Once SW2 started sending BPDUs again, SW3 logged %SPANTREE-2-LOOPGUARD_UNBLOCK and the port returned to Altn BLK on its own, as soon as the BPDUs arrived. Loop guard can also be turned on for every point-to-point port at once with spanning-tree loopguard default, while root guard is configured per port. One port can’t run both guards, so if a port already has root guard, leave loop guard off it.
BPDU guard, root guard and loop guard compared
You will mix these three up at some point, so here they are side by side as they behaved on our lab switches.
| Guard | Put it on | Triggers when | What happens | Recovery |
|---|---|---|---|---|
| BPDU guard | Host-facing PortFast ports | Any BPDU arrives | Port err-disabled | Manual, or errdisable recovery |
| Root guard | Designated ports toward switches that must not be root | A superior BPDU arrives | Port root-inconsistent (blocked) | Automatic when superior BPDUs stop |
| Loop guard | Root and alternate ports on switch links | Expected BPDUs stop arriving | Port loop-inconsistent (blocked) | Automatic when BPDUs return |
Recovery is the column that matters when you troubleshoot. show errdisable recovery on SW3 lists bpduguard as a cause but nothing for root guard or loop guard, because those two never err-disable a port. If a switch link is up but passing nothing, check show spanning-tree inconsistentports before you start bouncing interfaces.
Practice Spanning Tree Protocol
Root guard, loop guard and BPDU guard are named together in the Rapid PVST+ topic of Switching and Network Access in the CCNA v2.0 topics, and the Domain 2 practice test drills it with the rest of that domain. It is covered in the CCNA 200-301 study roadmap. The three-switch triangle, paste-ready for GNS3, Cisco Packet Tracer, or real gear, is in the companion repo: c4geeks/ccna-labs. Build SW1, SW2, and SW3, wire the triangle, paste the configs, and watch STP block one port on its own.
Test the root election, port roles, and cost math with the quiz:
CCNA practice: Domain 2: Switching and Network Access
10 questions drawn fresh from 129 in the bank, with the answer and explanation after each one.
Start 10 questionsThen drill the roles, states, and numbers with the flashcards, or load the deck into Anki:
STP port roles and states at a glance
Reading a spanning-tree topology comes down to four checks, in order:
- Who is root? The lowest Bridge ID (priority, then MAC). On the root,
show spanning-treesays “This bridge is the root” and every port is Desg FWD. - Which port is the root port? On each non-root switch, the one port with the lowest path cost to the root (1 Gbps = 4, 100 Mbps = 19). It is always forwarding.
- Which port is blocked? The alternate port (Altn BLK / discarding). It is the redundant path STP holds in reserve, and it is where you confirm the loop was broken.
- Is it converging fast?
show spanning-tree summaryshould read rapid-pvst, not the slower classic mode. Pair it with PortFast and BPDU Guard on host ports, the same way you would verify neighbors with CDP and LLDP.
Run those four checks against the output and a spanning-tree topology stops being a guess. The numbers decide the tree, and the numbers are all in show spanning-tree.