spanning-tree port-priority [value]
Sets the port priority value for a specific interface to influence which port becomes the root port in a Spanning Tree topology.
Definition: spanning-tree port-priority [value] is a Cisco IOS interface config command. Sets the port priority value for a specific interface to influence which port becomes the root port in a Spanning Tree topology.
Overview
The `spanning-tree port-priority [value]` command, issued in interface configuration mode, sets the port priority for a specific switch port. Port priority is a key component in the Spanning Tree Protocol (STP) root port selection process. When a switch receives multiple Bridge Protocol Data Units (BPDUs) from the root bridge on different ports, it must choose one as the root port.
The decision is based on the lowest root path cost; if costs are equal, the port with the lowest port priority is selected. By default, all ports have a priority of 128, but you can adjust this value (in increments of 16, from 0 to 240) to influence which port becomes the root port. This command is particularly useful in redundant topologies where you want to force a specific link to be the root port, ensuring deterministic traffic flow and optimal use of high-bandwidth links.
It is an alternative to adjusting path costs (via `spanning-tree cost`) or manipulating bridge priority; port priority offers a finer granularity for per-port control. In a typical workflow, you would first verify the current STP state with `show spanning-tree`, identify the root port and alternate ports, then adjust port priority on the desired interface to make it the root port. The command takes effect immediately and is saved to the running configuration.
Note that port priority is only relevant for the root port selection; it does not affect designated port selection (which uses bridge priority and port priority from the sending bridge). Also, the command is supported in PVST+, Rapid PVST+, and MSTP modes. Misconfiguration can lead to suboptimal forwarding paths or temporary loops if not coordinated with other STP parameters.
Understanding this command is essential for CCNA and CCNP candidates to design resilient Layer 2 networks.
spanning-tree port-priority [value]When to Use This Command
- Manually selecting a preferred root port on a non-root bridge to control traffic flow.
- Load balancing traffic across redundant links by adjusting port priorities.
- Ensuring a specific high-bandwidth link becomes the root port for faster convergence.
- Preventing a slow or unreliable link from being elected as the root port.
Parameters
| Parameter | Syntax | Description |
|---|---|---|
| value | <0-240> | Sets the port priority for the interface. Valid values are multiples of 16: 0, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192, 208, 224, 240. The default is 128. Lower values increase the likelihood of the port becoming the root port. A common mistake is using non-multiple values; the switch will reject them. |
Command Examples
Setting port priority to 64 on GigabitEthernet0/1
spanning-tree port-priority 64Switch(config-if)# spanning-tree port-priority 64 Switch(config-if)# end Switch# show spanning-tree interface gigabitEthernet 0/1 Vlan Role Sts Cost Prio.Nbr Type ------------------- ---- --- --------- -------- -------------------------------- VLAN0001 Root FWD 4 64.1 P2p VLAN0010 Desg FWD 4 64.1 P2p
The 'spanning-tree port-priority 64' command sets the priority to 64 for this interface. The 'show spanning-tree interface' output shows the port role (Root or Desg), state (FWD), cost, and the priority.nbr (64.1). The priority value (64) is lower than default (128), making this port more likely to be selected as root port.
Verifying port priority change on FastEthernet0/1
spanning-tree port-priority 32Switch(config-if)# spanning-tree port-priority 32
Switch(config-if)# end
Switch# show spanning-tree vlan 1
VLAN0001
Spanning tree enabled protocol ieee
Root ID Priority 32769
Address 0011.2233.4455
This bridge is the root
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32769 (priority 32768 sys-id-ext 1)
Address 0011.2233.4455
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300 sec
Interface Role Sts Cost Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/1 Desg FWD 19 32.1 P2p
Fa0/2 Desg FWD 19 128.2 P2pAfter setting priority to 32 on Fa0/1, the 'show spanning-tree vlan 1' output shows Fa0/1 with priority 32.1 (priority 32, port number 1). The lower priority makes it more favorable, but since this bridge is root, both ports are designated. The priority influences which port becomes root on downstream switches.
Understanding the Output
The 'show spanning-tree' or 'show spanning-tree interface' command displays the spanning-tree state per VLAN. The 'Pri.Nbr' column shows the port priority (first number) and port number (second number). Lower priority values make a port more likely to be elected as the root port.
In the output, 'Role' indicates the port role (Root, Desg, Altn, Back), and 'Sts' shows the state (FWD, BLK, LRN, LSN). A priority of 128 is default; values from 0 to 240 in increments of 16 are valid. If you see a port with a lower priority than others on the same switch, that port is preferred for root port selection.
Watch for misconfigurations where a port with a high priority (e.g., 240) might be blocked unnecessarily.
Configuration Scenarios
Force a specific port to become root port in a triangle topology
In a network with three switches in a triangle, SW1 is the root bridge. SW2 has two equal-cost paths to the root (via SW3 and directly to SW1). We want SW2's direct link to SW1 to be the root port, but due to default port priorities, the path via SW3 is chosen. We adjust port priority on SW2's direct link.
Topology
SW1(Gi0/1)---10.0.1.0/24---(Gi0/1)SW2
SW1(Gi0/2)---10.0.2.0/24---(Gi0/2)SW3
SW3(Gi0/1)---10.0.3.0/24---(Gi0/2)SW2Steps
- 1.Step 1: Enter privileged EXEC mode: SW2> enable
- 2.Step 2: Enter global configuration mode: SW2# configure terminal
- 3.Step 3: Enter interface configuration for the direct link to SW1: SW2(config)# interface gigabitethernet0/1
- 4.Step 4: Set port priority to 64 (lower than default 128): SW2(config-if)# spanning-tree port-priority 64
- 5.Step 5: Exit and verify: SW2(config-if)# end
- 6.Step 6: Verify root port selection: SW2# show spanning-tree
! Full IOS config block SW2# configure terminal SW2(config)# interface gigabitethernet0/1 SW2(config-if)# spanning-tree port-priority 64 SW2(config-if)# end
Verify: Use `show spanning-tree` on SW2. Look for the root port (Role: Root) on Gi0/1. Expected output snippet: 'Gi0/1' with 'Role Root' and 'Prio 64'.
Watch out: Ensure that the port priority is set on the non-root bridge, not the root bridge. Port priority only matters for root port selection on non-root bridges.
Ensure a specific port becomes designated port in a shared segment
Two switches (SW1 and SW2) are connected via two links. SW1 is the root bridge. On the shared segment between SW1 and SW2, both ports are designated (since SW1 is root). However, if SW2's port priority is lowered, it could become designated instead of SW1's port, causing a loop. This scenario demonstrates using port priority to force SW1's port to remain designated.
Topology
SW1(Gi0/1)---10.0.12.0/24---(Gi0/1)SW2
SW1(Gi0/2)---10.0.13.0/24---(Gi0/2)SW2Steps
- 1.Step 1: On SW1, enter interface configuration for Gi0/1: SW1# configure terminal
- 2.Step 2: SW1(config)# interface gigabitethernet0/1
- 3.Step 3: Set port priority to 0 (lowest possible): SW1(config-if)# spanning-tree port-priority 0
- 4.Step 4: Exit: SW1(config-if)# end
- 5.Step 5: Verify on SW1: SW1# show spanning-tree
! Full IOS config block SW1# configure terminal SW1(config)# interface gigabitethernet0/1 SW1(config-if)# spanning-tree port-priority 0 SW1(config-if)# end
Verify: On SW1, `show spanning-tree` should show Gi0/1 as designated (Role: Desg) with priority 0. On SW2, the corresponding port should be alternate (Role: Altn).
Watch out: Setting port priority to 0 on the root bridge's port does not affect root port selection on other switches; it only influences designated port election on that segment. If both switches set low priorities, a tie may occur, resolved by lower bridge ID.
Troubleshooting with This Command
When troubleshooting STP issues, the `spanning-tree port-priority` command is often used to correct suboptimal root port selection. Healthy output from `show spanning-tree` shows each port with a role (Root, Designated, Alternate, Backup) and a priority value. The root port should be on the path with the lowest cost to the root bridge; if costs are equal, the port with the lowest priority becomes root.
A problem indicator is when a high-bandwidth link is not chosen as the root port, or when a port that should be blocking is forwarding. To diagnose, first identify the root bridge with `show spanning-tree` and note the root ID. Then examine each non-root switch's root port.
If the root port is not the expected one (e.g., a slower link), check the port priority on the candidate ports. Use `show spanning-tree interface [interface] detail` to see the port priority and cost. If the priority is default (128) and costs are equal, the port with the lower neighbor bridge ID wins.
To force a specific port, lower its priority. Common symptoms: traffic taking a suboptimal path, high latency, or loops. A step-by-step diagnostic flow: 1) Identify the root bridge. 2) On each non-root switch, list all ports and their root path costs. 3) If costs are equal, compare port priorities. 4) If priorities are equal, the lower neighbor bridge ID decides. 5) Adjust port priority on the desired port to a lower value (e.g., 64 or 32). 6) Verify with `show spanning-tree` that the role changed.
Correlate with `debug spanning-tree events` to see BPDU exchanges. Note that changing port priority does not affect the root bridge itself; it only influences root port selection on downstream switches. Also, in Rapid PVST+, the same logic applies.
If you see unexpected blocking, check for port priority misconfiguration or inconsistent values across redundant links.
CCNA Exam Tips
CCNA exam tip: Port priority values must be multiples of 16 (0, 16, 32, ..., 240).
CCNA exam tip: The default port priority is 128; lowering it makes the port more likely to become root port.
CCNA exam tip: Port priority is used as a tie-breaker when path costs are equal.
CCNA exam tip: Remember that port priority is configured per interface, not globally.
Common Mistakes
Mistake: Setting port priority to a non-multiple of 16 (e.g., 50) — the IOS will reject it.
Mistake: Confusing port priority with bridge priority — port priority is per interface, bridge priority is per switch.
Mistake: Forgetting to apply the command in interface configuration mode.
spanning-tree port-priority [value] vs spanning-tree cost [value]
Both commands influence Spanning Tree Protocol decisions at the interface level, but they affect different STP metrics: port priority for root port selection and path cost for overall topology cost. They are commonly compared because both can manually influence STP outcomes, leading to confusion about their roles.
| Aspect | spanning-tree port-priority [value] | spanning-tree cost [value] |
|---|---|---|
| Scope | Port-specific priority value | Port-specific path cost value |
| Configuration mode | Interface configuration | Interface configuration |
| Persistence | Persists in running-config; saved to startup-config | Persists in running-config; saved to startup-config |
| Precedence | Lower priority increases likelihood of becoming root port | Lower cost makes path more preferred in STP calculations |
| Typical use | Forcing a specific interface to become root port | Adjusting path cost to influence root port or alternate path selection |
Use spanning-tree port-priority [value] when you want to directly influence which specific interface on a bridge becomes the root port, typically by assigning a lower priority to the desired link.
Use spanning-tree cost [value] when you need to adjust the perceived cost of a link to affect STP path selection, such as to prefer a higher-bandwidth link or to steer traffic away from a less desirable path.
Platform Notes
In IOS-XE (e.g., Catalyst 9000 series), the command syntax is identical: `spanning-tree port-priority [value]` under interface configuration. Output format in `show spanning-tree` is similar, but newer versions may display additional fields like 'Type' (P2p, Shared). In NX-OS (e.g., Nexus switches), the equivalent command is `spanning-tree port-priority [value]` under interface configuration as well, but NX-OS uses a different STP implementation (MSTP by default).
The command works in both PVST+ and MSTP modes. For ASA firewalls, STP is not typically used; the command does not exist. In IOS-XR (e.g., ASR 9000), STP is not supported; instead, use Ethernet OAM or other Layer 2 protocols.
Between IOS versions (12.x, 15.x, 16.x), the command behavior is consistent, but the output of `show spanning-tree` may vary slightly in formatting. For example, IOS 12.x shows 'Port 1 (GigabitEthernet0/1)' while 15.x shows 'Gi0/1'. Always verify with the specific IOS version documentation.
Related Commands
show spanning-tree
Displays the Spanning Tree Protocol (STP) state and configuration for all VLANs or a specific VLAN, used to verify root bridge, port roles, and STP topology.
spanning-tree cost [value]
Sets the path cost for a specific interface in Spanning Tree Protocol (STP) calculations, overriding the default cost based on interface speed.
Practice for the CCNA 200-301
Test your knowledge with practice questions covering all CCNA 200-301 exam domains.
Practice CCNA 200-301 Questions