STP Port Roles – Root Port, Designated Port, Alternate, Backup & Selection Rules
1. Why Port Roles Exist — The Loop Problem
Ethernet networks with redundant switch links provide resilience — if one path fails, traffic can take another route. But without a mechanism to manage those redundant paths, Layer 2 loops form immediately when a device sends a broadcast. Switches flood broadcasts out every port except the ingress, creating frames that circulate indefinitely, consuming all bandwidth within seconds.
Redundant links WITHOUT STP: PC-A sends a broadcast frame. SW1 floods it to SW2 and SW3. SW2 floods it back to SW1 and SW3. SW3 floods it back to SW1 and SW2. Each switch multiplies the frame -- the loop is instantaneous and fatal. Layer 2 loop consequences: 1. Broadcast storm -- 100% bandwidth consumed within seconds 2. MAC table instability -- same MAC learned on multiple ports 3. Multiple frame delivery -- same unicast frame received many times 4. Network unusable -- all user traffic displaced by storm frames STP solution: assign each port a ROLE that determines whether it forwards traffic or blocks it, creating a loop-free tree topology while keeping redundant paths in standby.
Related pages: Root Bridge Election | STP Port States | RSTP (Rapid STP) Lab | PortFast & BPDU Guard | MAC Address Table | Spanning Tree Root Bridge Lab | PortFast & BPDU Guard Lab
2. Overview — All STP Port Roles
| Role | Code in show spanning-tree | Forwards User Traffic? | Learns MACs? | Quantity per Switch | STP Version |
|---|---|---|---|---|---|
| Root Port (RP) | Root | Yes | Yes | Exactly one (except on Root Bridge — zero) | STP, RSTP, PVST+, Rapid PVST+ |
| Designated Port (DP) | Desg | Yes | Yes | One per segment; multiple per switch | STP, RSTP, PVST+, Rapid PVST+ |
| Blocking Port | Altn / BLK | No | No | Zero or more | Classic STP (802.1D) only |
| Alternate Port | Altn | No (discarding) | No | Zero or more | RSTP (802.1w), Rapid PVST+ |
| Backup Port | Back | No (discarding) | No | Zero or more | RSTP (802.1w), Rapid PVST+ |
| Disabled | Disabled | No | No | Zero or more | All versions |
3. STP Path Cost — The Foundation of Role Selection
STP assigns a path cost to each port based on its link speed. Lower cost = better path. Path costs are cumulative — each switch adds the cost of the incoming port to its running total as it calculates the path to the Root Bridge.
| Link Speed | IEEE 802.1D Cost (Long) | IEEE 802.1D Cost (Short) | Notes |
|---|---|---|---|
| 10 Gbps | 2 | 2 | 10GE uplinks, data centre interconnects |
| 1 Gbps | 4 | 4 | Modern standard for access-distribution uplinks |
| 100 Mbps | 19 | 19 | Fast Ethernet — still common on older access switches |
| 10 Mbps | 100 | 100 | Legacy Ethernet — rarely seen in modern networks |
Path cost accumulation example:
Root Bridge
| (Gi0/1 = 1 Gbps, cost 4)
SW1 -- Root Port cost to root = 4
| (Fa0/1 = 100 Mbps, cost 19)
SW2 -- Root Port cost to root = 4 + 19 = 23
| (Fa0/2 = 100 Mbps, cost 19)
SW3 -- Root Port cost to root = 4 + 19 + 19 = 42
Each switch adds the INCOMING PORT'S cost (the port facing the root).
The OUTGOING port cost toward the root is NOT added by this switch --
it is added by the next switch downstream.
Important: You add the cost of the PORT YOU RECEIVE BPDUs ON,
not the port you send them out of.
Manually Overriding Port Cost
! Override the default cost on a specific port: Switch(config)# interface GigabitEthernet0/1 Switch(config-if)# spanning-tree vlan 10 cost 10 ! Lowering cost makes this port more likely to become Root Port ! Raising cost makes it less preferred ! Verify: Switch# show spanning-tree vlan 10 Interface Role Sts Cost Prio.Nbr Type Gi0/1 Root FWD 10 128.1 P2p <-- custom cost applied
4. Root Port (RP) — Selection and Tiebreakers
The Root Port is the port on a non-root switch that provides the best (lowest cumulative cost) path to the Root Bridge. Every non-root switch has exactly one Root Port. The Root Bridge itself has no Root Port — all its ports are Designated Ports.
Root Port selection — four-level tiebreaker process: Tiebreaker 1: Lowest TOTAL path cost to Root Bridge (sum of all port costs along the path from this switch to root) Tiebreaker 2: Lowest SENDER Bridge ID (if two upstream neighbours offer equal path cost, prefer the one with the lower BID -- the more preferred neighbour is the better path) Tiebreaker 3: Lowest SENDER Port ID (priority + port number) (if the same upstream switch has two links to this switch and offers equal path cost on both, prefer the link from the upstream switch's lower-priority/lower-numbered port) Tiebreaker 4: Lowest LOCAL Port ID (final tiebreaker: on THIS switch, prefer the port with the lower priority, then lower port number) The vast majority of elections are decided at Tiebreaker 1. Tiebreaker 2 handles multi-path topologies. Tiebreakers 3 and 4 handle parallel links between the same switches.
Root Port selection example — triangle topology: SW-Root (Priority 4096) Gi0/1 -------- Gi0/1 SW-A (Priority 32769) Gi0/2 -------- Gi0/2 SW-B (Priority 32769) SW-A Gi0/2 --- SW-B Gi0/1 On SW-A: Gi0/1: cost 4 to reach SW-Root via one Gigabit hop Gi0/2: cost 4 + 4 = 8 to reach SW-Root via SW-B then SW-Root Winner: Gi0/1 becomes Root Port (cost 4 < 8) On SW-B: Gi0/2: cost 4 to reach SW-Root via one Gigabit hop Gi0/1: cost 4 + 4 = 8 to reach SW-Root via SW-A then SW-Root Winner: Gi0/2 becomes Root Port (cost 4 < 8)
Root Port — Key Facts
- One per non-root switch, always — no exceptions. If a switch has multiple paths to the root, one wins; the others are blocked (or become Alternate Ports in RSTP).
- Always in Forwarding state during normal operation — frames flow toward the root through this port.
- The Root Bridge has zero Root Ports — it IS the root; there is no "path to itself."
- Traffic on the Root Port flows toward the Root Bridge (upstream).
5. Designated Port (DP) — Selection and Tiebreakers
Every network segment (link between two switches) must have exactly one Designated Port — the port that will forward traffic toward the Root Bridge on behalf of that segment. There is one DP per segment, and a switch can have many DPs — one for each segment it connects to.
Designated Port — what "per segment" means: SW-Root --- SW-A (two switches, one segment between them) This segment needs exactly ONE designated port. Root Bridge's port toward SW-A: path cost to root = 0 (IS the root) SW-A's port toward SW-Root: path cost to root = 4 (Gi uplink) Winner: Root Bridge's port (cost 0 < cost 4) becomes Designated Port SW-A's port toward root becomes ROOT PORT (not Designated) Rule: The Root Bridge ALWAYS has all Designated Ports. Its cost to reach itself = 0 -- unbeatable by any other switch.
Designated Port on a non-root segment:
SW-A (Root Port on Gi0/1, cost 4 to root)
|
SW-B Gi0/1 -- SW-A Gi0/2 (segment between SW-A and SW-B)
Both SW-A (Gi0/2) and SW-B (Gi0/1) are candidates for DP on this segment.
SW-A's Gi0/2: SW-A's total cost to root = 4. Offers cost 4 to reach root.
SW-B's Gi0/1: SW-B's total cost to root = 4 + 4 = 8 (via SW-A) or 4 (via SW-Root).
(Assume SW-B also has direct link to root at cost 4: then it's a tie -- see tiebreakers)
Tiebreaker sequence for Designated Port selection:
1. Lowest accumulated path cost to root (this side vs other side)
2. Lowest Bridge ID of the switch (SW-A vs SW-B BID comparison)
3. Lowest Port ID on the winning switch
The NON-winning port on the segment becomes Blocking / Alternate.
Designated Port — Key Facts
- One per segment — exactly one DP per link between two switches.
- Multiple per switch allowed — the Root Bridge has one DP on every link; distribution switches often have several DPs toward access switches.
- Always in Forwarding state — DPs carry traffic away from the root toward downstream switches.
- All Root Bridge ports are Designated — the root's cost to reach itself is 0, so it always wins the DP election on every directly connected segment.
6. Blocking Port (Classic STP) / Alternate Port (RSTP)
Any port that is neither a Root Port nor a Designated Port is placed in a non-forwarding role. In classic STP (802.1D) this is simply called a Blocking Port. In RSTP (802.1w) the same concept is split into two more specific roles: Alternate and Backup.
Triangle topology — complete role assignment:
SW-Root (Root Bridge)
/ \
Gi0/1 (DP) Gi0/2 (DP)
| |
SW-A SW-B
Gi0/1 (Root Port) Gi0/1 (Root Port)
Gi0/2 (DP) Gi0/2 (Altn/BLK) <-- blocked to break the loop
\ /
--- SW-A Gi0/2 -- SW-B Gi0/2 ---
segment
On the SW-A to SW-B segment:
SW-A's Gi0/2: path cost to root via SW-A = 4 (SW-A's RP cost)
SW-B's Gi0/2: path cost to root via SW-B = 4 (SW-B's RP cost)
Tie on cost! -> Tiebreaker 2: compare BIDs
SW-A BID: 32769 + lower MAC -> wins if MAC is lower
SW-B BID: 32769 + higher MAC -> loses
Result: SW-A Gi0/2 = Designated Port (FWD)
SW-B Gi0/2 = Blocking / Alternate Port (BLK)
The loop is broken. SW-B Gi0/2 sits in standby --
if SW-A fails, it will activate to restore connectivity.
What a Blocking Port Still Does
- Receives BPDUs — a blocking port still listens for BPDUs so it knows when the topology changes and can react.
- Does NOT forward user frames — no data traffic in either direction.
- Does NOT learn MAC addresses — the CAM table is not updated from traffic on a blocking port.
- Can become Forwarding — if the Designated Port on this segment fails, the blocking port transitions to Designated and eventually Forwarding (after Listening + Learning in classic STP; immediately in RSTP via proposal/agreement).
7. Alternate and Backup Ports (RSTP)
RSTP (802.1w) refines the non-forwarding category into two distinct roles with different recovery behaviours, enabling the rapid convergence that makes RSTP so much faster than classic STP.
| Role | What It Is | What It Backs Up | Recovery Trigger | State |
|---|---|---|---|---|
| Alternate Port | Alternative path to the Root Bridge — an alternate Root Port waiting in standby | The current Root Port on this switch | Root Port fails → Alternate Port immediately becomes new Root Port (no timer delays in RSTP) | Discarding |
| Backup Port | Redundant connection to the same segment where this switch already has a Designated Port | The current Designated Port on the same segment | Designated Port fails → Backup Port becomes Designated Port | Discarding |
Alternate Port scenario: SW-B has two paths to Root Bridge -- via SW-A and directly via Gi0/3. Gi0/1: Root Port (cost 4, best path via SW-A uplink) Gi0/3: Alternate Port (cost 8, longer path direct) Root Port fails (Gi0/1 link down): RSTP: Gi0/3 (Alternate) immediately transitions to Root Port No timers needed -- direct promotion (sub-second convergence) Backup Port scenario (rare -- requires hub or shared segment): SW-A connects to a hub with TWO ports (Gi0/4 and Gi0/5) Gi0/4: Designated Port (better port ID -- lower priority or port number) Gi0/5: Backup Port (same segment as Gi0/4 -- redundant DP to the same hub) Backup ports are uncommon in modern networks (hubs are obsolete) but the concept appears on CCNA exams.
8. Complete Port Role Selection Algorithm
Step-by-step port role assignment for every switch in the network: STEP 1: ROOT BRIDGE ELECTION The switch with the lowest Bridge ID becomes Root Bridge. All ports on the Root Bridge become DESIGNATED PORTS. (Root Bridge cost to itself = 0, always wins every segment election) STEP 2: ROOT PORT SELECTION (on every non-root switch) For each non-root switch, select the port with: -> Lowest cumulative path cost to Root Bridge (main criterion) -> If tied: lowest Sender Bridge ID (tiebreaker 2) -> If tied: lowest Sender Port ID (tiebreaker 3) -> If tied: lowest Local Port ID (tiebreaker 4) This port becomes the ROOT PORT (forwarding). STEP 3: DESIGNATED PORT SELECTION (per segment) For every segment (link between two switches): Both ends compare their path cost to root: -> Lower cost side becomes DESIGNATED PORT (forwarding) -> If tied: lower Bridge ID wins -> If tied: lower Port ID wins The Root Bridge always wins (cost = 0) STEP 4: BLOCKING / ALTERNATE PORT Any port that is neither Root Port nor Designated Port is: -> BLOCKING PORT (classic STP 802.1D) -> ALTERNATE PORT (RSTP 802.1w, if it's an alternate path to root) -> BACKUP PORT (RSTP 802.1w, if it's redundant on same segment as DP)
9. Port Role vs Port State — The Critical Distinction
Port roles and port states are two separate but related concepts. Roles describe function in the topology; states describe operational condition.
| Port State (Classic STP) | Duration | Sends/Receives BPDUs? | Learns MACs? | Forwards Traffic? |
|---|---|---|---|---|
| Blocking | Max Age (20 sec default) | Receives only | No | No |
| Listening | Forward Delay (15 sec) | Yes — sends and receives | No | No |
| Learning | Forward Delay (15 sec) | Yes | Yes | No |
| Forwarding | Indefinite (normal operation) | Yes | Yes | Yes |
| Disabled | Until re-enabled | No | No | No |
The relationship between roles and states during normal operation:
| Port Role | Normal State | Transitional States |
|---|---|---|
| Root Port | Forwarding | Blocking → Listening → Learning → Forwarding (30 sec in STP) |
| Designated Port | Forwarding | Blocking → Listening → Learning → Forwarding (30 sec in STP) |
| Blocking Port | Blocking | Transitions to Listening if topology changes |
| Alternate Port (RSTP) | Discarding | Discarding → Forwarding immediately on RP failure (RSTP) |
| Backup Port (RSTP) | Discarding | Discarding → Forwarding on DP failure (RSTP) |
See STP Port States for the complete state machine, timer values, and transition diagrams.
10. Reading show spanning-tree — Port Role Output
Switch# show spanning-tree vlan 10
VLAN0010
Spanning tree enabled protocol rstp
Root ID Priority 4097
Address 0011.1111.1111
Cost 4
Port 1 (GigabitEthernet0/1) <-- Root Port is Gi0/1
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32778 (priority 32768 sys-id-ext 10)
Address 0044.4444.4444
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 <-- Root Port (FWD)
Gi0/2 Desg FWD 4 128.2 P2p <-- Designated Port (FWD)
Gi0/3 Altn BLK 4 128.3 P2p <-- Alternate/Blocked (BLK)
Fa0/1 Desg FWD 19 128.4 P2p <-- Designated (FastEth cost 19)
Fa0/2 Desg FWD 19 128.5 P2p <-- Designated
! Role column codes:
! Root = Root Port (forwarding toward Root Bridge)
! Desg = Designated Port (forwarding away from Root Bridge to segment)
! Altn = Alternate Port (blocked, alternate path to root -- RSTP)
! Back = Backup Port (blocked, redundant to same segment -- RSTP)
! Mstr = Master Port (MST specific)
! Sts (State) column codes:
! FWD = Forwarding (active, passing user traffic)
! BLK = Blocking/Discarding (not forwarding user traffic)
! LIS = Listening (transitional -- classic STP only)
! LRN = Learning (transitional -- learning MACs, not yet forwarding)
! DIS = Disabled
! Cost column: current STP cost configured on this port
! Prio.Nbr: Port priority (default 128) + port number (e.g., 128.1 = priority 128, port 1)
show spanning-tree per-interface and summary
! Check one interface: Switch# show spanning-tree interface GigabitEthernet0/1 Vlan Role Sts Cost Prio.Nbr Type ------------------- ---- --- --------- -------- ---- VLAN0001 Root FWD 4 128.1 P2p VLAN0010 Root FWD 4 128.1 P2p ! Check all VLANs summary: Switch# show spanning-tree summary Switch is in rapid-pvst mode Root bridge for: Vlan0001 Name Blocking Listening Learning Forwarding STP Active ---------------------- -------- --------- -------- ---------- ---------- VLAN0001 1 0 0 3 4 VLAN0010 0 0 0 4 4
11. Port Priority — Influencing Role Selection
When path costs are equal and BIDs are equal (parallel links between the same two switches), the port priority (part of the Port ID) becomes the tiebreaker. Lower port priority = preferred port. Port priority can be manually tuned to influence which port becomes Root Port or Designated Port.
! Default port priority = 128. Range: 0–240 in increments of 16. ! Lower value = preferred. ! Influence which port on THIS switch is preferred by a downstream switch ! (affects the downstream switch's Root Port selection): Switch(config)# interface GigabitEthernet0/1 Switch(config-if)# spanning-tree vlan 10 port-priority 64 ! Setting lower port priority on Gi0/1 makes it the preferred port ! for downstream switches to use as their Root Port toward this switch ! Verify port priority in show spanning-tree: ! Prio.Nbr = 64.1 means port priority 64, port number 1 ! Prio.Nbr = 128.2 means port priority 128 (default), port number 2
12. PortFast and BPDU Guard — Edge Port Roles
Access ports connected to end devices (PCs, printers, IP phones) go through STP's Listening + Learning states by default (30 seconds) before forwarding. PortFast skips these transitional states, putting the port immediately into Forwarding. BPDU Guard protects PortFast ports from rogue switches.
! Enable PortFast on an access port: Switch(config-if)# switchport mode access Switch(config-if)# spanning-tree portfast ! Port immediately enters Forwarding state when a device connects ! PC gets network access in seconds instead of 30+ seconds ! WARNING: Never enable PortFast on ports connected to other switches ! Enable BPDU Guard (protects PortFast ports from switches): Switch(config-if)# spanning-tree bpduguard enable ! Port enters err-disabled if any BPDU is received ! Prevents a rogue switch connected to an access port from participating in STP ! Enable PortFast globally on all access ports: Switch(config)# spanning-tree portfast default ! Enable BPDU Guard globally on all PortFast-enabled ports: Switch(config)# spanning-tree portfast bpduguard default
See PortFast & BPDU Guard for detailed configuration and port security implications.
13. RSTP Port Roles Compared to Classic STP
| Classic STP (802.1D) | RSTP (802.1w) Equivalent | Key Difference |
|---|---|---|
| Root Port | Root Port | Same role; RSTP transitions to forwarding faster via proposal/agreement mechanism instead of timer wait |
| Designated Port | Designated Port | Same role; RSTP uses proposal/agreement for rapid forwarding transition (no 30-second wait) |
| Blocking Port | Alternate Port | Explicitly named as "Alternate" in RSTP; can immediately become Root Port on failure — no timer delays |
| Blocking Port | Backup Port | Specifically for redundant connections to the same segment; can immediately become Designated Port on failure |
| Disabled | Disabled | Same |
See RSTP (Rapid STP) Lab for the proposal/agreement mechanism that enables near-instant convergence.
14. Troubleshooting Port Roles
| Symptom | Likely Cause | Diagnostic Command | Fix |
|---|---|---|---|
| Broadcast storm / MAC table instability | STP not blocking a redundant port — a loop exists. Possibly STP disabled, or a port that should be blocking is Forwarding | show spanning-tree — look for unexpected FWD
ports; check for ports not participating in STP |
Verify STP is running; check for unmanaged switches (no STP) creating loops; verify PortFast not enabled on inter-switch links |
| Unexpected Root Port or suboptimal path | Unintended Root Bridge (low MAC wins by default); wrong port costs; misconfigured port priority | show spanning-tree vlan [id] — check Root ID
and port costs; show spanning-tree root |
Configure correct root with spanning-tree vlan [id]
root primary; adjust port costs or priority to
influence path selection |
| Port stuck in Listening or Learning state | STP convergence in progress — timing issue; or a topology change notification is causing repeated transitions | show spanning-tree vlan [id] detail — check
topology change count; debug spanning-tree events |
Investigate topology changes with show spanning-tree
detail | include topology; fix instability at source |
| Access port takes 30+ seconds to come up | PortFast not enabled on end-device ports — STP running Listening + Learning states unnecessarily | show spanning-tree interface Fa0/x — if PortFast
shows "not enabled," that's the issue |
spanning-tree portfast on access ports;
add spanning-tree bpduguard enable for security |
| Port in err-disabled after BPDU received | BPDU Guard triggered — a switch was connected to a PortFast-enabled port | show interfaces status err-disabled;
show port-security interface [int] |
Remove the switch; recover port with
shutdown / no shutdown; investigate
why a switch was connected to an access port |
Key Verification Commands
Switch# show spanning-tree ! All VLANs, all ports Switch# show spanning-tree vlan 10 ! VLAN 10 only -- roles + states Switch# show spanning-tree vlan 10 detail ! Verbose -- timers, topology changes Switch# show spanning-tree interface Gi0/1 ! One port across all VLANs Switch# show spanning-tree root ! Root bridge per VLAN table Switch# show spanning-tree summary ! Count of ports per state Switch# show spanning-tree inconsistentports ! Ports in root-inconsistent state
15. Key Points & Exam Tips
- Root Port: One per non-root switch. Best path to Root Bridge. Always Forwarding. Root Bridge has ZERO Root Ports.
- Designated Port: One per segment. Best port for a link. Multiple per switch. Always Forwarding. All Root Bridge ports are Designated.
- Blocking / Alternate Port: Neither RP nor DP. Not forwarding. Receives BPDUs. Activates if RP or DP fails.
- Selection tiebreakers (in order): (1) Lowest path cost to root, (2) Lowest sender BID, (3) Lowest sender Port ID, (4) Lowest local Port ID. Most elections resolved at step 1.
- Path costs: 10 Gbps = 2, 1 Gbps = 4, 100 Mbps = 19, 10 Mbps =
100. Lower cost = preferred. Can be manually overridden with
spanning-tree vlan [id] cost [value]. - Role vs State: Role = function in topology (RP, DP, Alternate). State = operational condition (Forwarding, Blocking, Listening, Learning). A Root Port in normal operation has role=Root, state=FWD.
- RSTP additions: Alternate Port (backs up Root Port) and Backup Port (backs up Designated Port on same segment). Both are Discarding. Enable immediate failover without timer delays.
- PortFast: Skips Listening+Learning (30 sec wait). Use only on access ports to end devices. Never on inter-switch links.
- BPDU Guard: Err-disables a PortFast port if any BPDU received. Protects against rogue switch connections to access ports.
- show spanning-tree is the primary diagnostic command. Check Role and Sts columns. Role codes: Root, Desg, Altn, Back. State codes: FWD, BLK, LIS, LRN, DIS.
Related pages: Root Bridge Election | STP Port States | RSTP (Rapid STP) Lab | PortFast & BPDU Guard | MAC Address Table | Spanning Tree Root Bridge Lab | PortFast & BPDU Guard Lab