Courseiva
Spanning TreeGlobal Config

spanning-tree vlan [id] priority [value]

Sets the bridge priority for a specific VLAN to influence the root bridge election in Spanning Tree Protocol (STP).

Definition: spanning-tree vlan [id] priority [value] is a Cisco IOS global config command. Sets the bridge priority for a specific VLAN to influence the root bridge election in Spanning Tree Protocol (STP).

Overview

The `spanning-tree vlan [id] priority [value]` command is a fundamental tool for influencing the Spanning Tree Protocol (STP) root bridge election in a per-VLAN context. STP is a Layer 2 protocol that prevents loops in Ethernet networks by creating a loop-free logical topology. The root bridge is the central reference point for all STP calculations; all switches in the network determine the best path to the root bridge.

By default, the switch with the lowest bridge ID (a combination of priority and MAC address) becomes the root. The bridge priority is a 16-bit value (0–65535) that defaults to 32768 for most Cisco switches. Lower values are preferred.

This command allows you to manually set the priority for a specific VLAN, overriding the default and ensuring a particular switch becomes the root bridge for that VLAN. This is critical in networks where you want to control traffic flow, optimize path selection, or enforce administrative policies. For example, you might want a core switch to be the root for all VLANs to ensure consistent forwarding paths.

Alternatively, you might set different roots for different VLANs to load-balance traffic across multiple distribution switches. The command is used in global configuration mode and immediately affects the running configuration. It does not require a reload.

The priority value must be a multiple of 4096 (except when using the `extended system-id` feature, which is enabled by default on modern IOS). Common mistakes include setting a priority that is not a multiple of 4096 (which is accepted but may cause unexpected behavior in some older IOS versions) or forgetting that the MAC address is used as a tiebreaker when priorities are equal. This command is preferred over manually setting the root bridge via `spanning-tree vlan [id] root primary` because it gives you exact control over the priority value.

The `root primary` command sets the priority to 24576 (or lower if a lower priority already exists), which may not be desirable in all designs. The command is available in IOS, IOS-XE, and NX-OS (with slight syntax differences). It is not available in IOS-XR, which uses a different STP implementation (MSTP with different configuration).

Understanding this command is essential for CCNA and CCNP candidates as it appears in both exam topics and real-world network design.

Syntax·Global Config
spanning-tree vlan [id] priority [value]

When to Use This Command

  • Ensuring a specific switch becomes the root bridge for a VLAN to optimize traffic flow.
  • Configuring a backup root bridge with a higher priority value for redundancy.
  • Adjusting priority to force a different switch to become root after a failure.
  • Troubleshooting STP convergence issues by manually controlling root bridge selection.

Parameters

ParameterSyntaxDescription
id<1-4094>The VLAN ID for which the priority is being set. Valid values are from 1 to 4094, excluding reserved VLANs (0, 1002-1005). Common mistake: using VLAN 1 (default) without considering that it may be used for management traffic.
value<0-61440>The bridge priority value. Must be a multiple of 4096 (e.g., 0, 4096, 8192, ..., 61440). The default is 32768. Lower values increase the chance of becoming root. Common mistake: using a value not a multiple of 4096; IOS accepts it but the priority is rounded down to the nearest multiple of 4096.

Command Examples

Set priority to 4096 for VLAN 10 to make switch root bridge

spanning-tree vlan 10 priority 4096

No output is displayed upon successful configuration. Use 'show spanning-tree vlan 10' to verify the new priority.

Verify priority change with show spanning-tree

show spanning-tree vlan 10
VLAN0010
  Spanning tree enabled protocol ieee
  Root ID    Priority    4096
             Address     0011.2233.4455
             This bridge is the root
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec

  Bridge ID  Priority    4096   (priority 4096 sys-id-ext 10)
             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
---------------- ---- --- --------- -------- --------------------------------
Gi0/0            Desg FWD 4         128.1    P2p
Gi0/1            Desg FWD 4         128.2    P2p

The 'Root ID' shows priority 4096 and the MAC address of this switch, confirming it is the root. 'This bridge is the root' indicates root status. 'Bridge ID' shows the configured priority (4096) plus the VLAN ID (10) as sys-id-ext. Interface roles: Desg (designated) and FWD (forwarding) are normal for root ports.

Understanding the Output

The 'show spanning-tree vlan [id]' command displays STP information for a specific VLAN. The 'Root ID' section shows the current root bridge's priority and MAC address. If 'This bridge is the root' appears, the local switch is the root.

The 'Bridge ID' section shows the local switch's priority (including the VLAN ID as sys-id-ext). Lower priority values (multiples of 4096) are better for becoming root. Interface roles: Root (R) for best path to root, Designated (Desg) for forwarding on segment, Alternate (Altn) or Backup (Back) for blocked ports.

State: FWD (forwarding), BLK (blocking), LRN (learning), LIS (listening). Cost is the path cost to root. Watch for unexpected root changes or blocked ports indicating loops.

Configuration Scenarios

Configure a Core Switch as Root Bridge for VLAN 10

In a network with multiple access switches, the core switch should be the root bridge for VLAN 10 to ensure optimal path selection and minimize latency for critical traffic.

Topology

CoreSW(Gi0/1)---trunk---(Gi0/1)AccessSW1 CoreSW(Gi0/2)---trunk---(Gi0/1)AccessSW2

Steps

  1. 1.Step 1: Enter global configuration mode on CoreSW: configure terminal
  2. 2.Step 2: Set the priority for VLAN 10 to 4096: spanning-tree vlan 10 priority 4096
  3. 3.Step 3: Exit configuration mode: end
  4. 4.Step 4: Verify the root bridge for VLAN 10: show spanning-tree vlan 10
Configuration
! CoreSW configuration
interface GigabitEthernet0/1
 switchport mode trunk
!
interface GigabitEthernet0/2
 switchport mode trunk
!
spanning-tree vlan 10 priority 4096
!

Verify: Use `show spanning-tree vlan 10` and look for 'Root ID' section. The bridge ID should show priority 4096 and the MAC address of CoreSW. Expected output snippet: 'Root ID Priority 4096'

Watch out: If another switch already has a priority lower than 4096, CoreSW will not become root. Use `show spanning-tree vlan 10` to check current root priority before configuring.

Load-Balance Traffic by Setting Different Root Bridges for Different VLANs

To distribute traffic across two distribution switches, set one as root for VLANs 10-20 and the other as root for VLANs 30-40, reducing congestion on a single switch.

Topology

Dist1(Gi0/1)---trunk---(Gi0/1)Core Dist2(Gi0/1)---trunk---(Gi0/2)Core Dist1(Gi0/2)---trunk---(Gi0/1)Access1 Dist2(Gi0/2)---trunk---(Gi0/2)Access2

Steps

  1. 1.Step 1: On Dist1, set priority for VLANs 10-20: spanning-tree vlan 10-20 priority 4096
  2. 2.Step 2: On Dist2, set priority for VLANs 30-40: spanning-tree vlan 30-40 priority 4096
  3. 3.Step 3: Verify on each switch: show spanning-tree vlan 10 and show spanning-tree vlan 30
Configuration
! Dist1 configuration
spanning-tree vlan 10-20 priority 4096
!
! Dist2 configuration
spanning-tree vlan 30-40 priority 4096
!

Verify: On Dist1, `show spanning-tree vlan 10` should show Dist1 as root. On Dist2, `show spanning-tree vlan 30` should show Dist2 as root. Use `show spanning-tree summary` to see root bridges for all VLANs.

Watch out: Ensure VLANs are created and trunked properly. If a VLAN is not present on a switch, the command will still be accepted but will have no effect until the VLAN is created.

Troubleshooting with This Command

When troubleshooting STP root bridge issues, the `show spanning-tree vlan [id]` command is your primary diagnostic tool. Healthy output shows the root bridge ID with the expected priority and MAC address. If the root bridge is not the intended switch, check the priority values on all switches.

Use `show spanning-tree vlan [id]` on each switch to see its own bridge ID and the root ID. Focus on the 'Bridge ID' and 'Root ID' fields. If the root ID differs from the intended switch, that switch has a lower priority or MAC address.

Common symptoms include suboptimal traffic flow (e.g., traffic traversing a slower link) or loops if STP is misconfigured. A step-by-step diagnostic flow: 1) Identify the VLAN experiencing issues. 2) On the suspected root switch, run `show spanning-tree vlan [id]` to confirm its priority. 3) On other switches, run the same command to see the root ID. 4) If the root is not the intended switch, check the priority of the current root using `show spanning-tree vlan [id]` on that switch. 5) Adjust priority on the intended root switch using `spanning-tree vlan [id] priority [value]`. 6) Verify the change takes effect immediately. Correlate with `show spanning-tree interface [interface]` to see port roles and states.

If a switch is not becoming root despite having the lowest priority, check for BPDU filter or guard configurations that might block BPDUs. Also verify that the VLAN exists on the switch and that the switch is running STP (not disabled). Use `debug spanning-tree events` to see root election changes in real time, but use with caution in production.

In multi-VLAN environments, use `show spanning-tree summary` to get an overview of root bridges for all VLANs. Remember that the extended system ID (VLAN ID) is included in the bridge ID, so two switches with the same priority but different MAC addresses will have different bridge IDs. The command `spanning-tree vlan [id] root primary` is an alternative that sets priority to 24576, but it may not be low enough if another switch has a priority of 0.

Always verify after configuration.

CCNA Exam Tips

1.

Priority values must be in increments of 4096 (0, 4096, 8192, etc.) on Cisco switches; other values are rejected.

2.

The root bridge is the switch with the lowest bridge ID (priority + MAC address). Changing priority can force a new root election.

3.

In CCNA, know that the default priority is 32768, and setting it to 0 makes the switch likely root.

4.

The 'sys-id-ext' automatically adds the VLAN ID to the priority, so effective priority = configured priority + VLAN ID.

Common Mistakes

Using a priority value not a multiple of 4096 (e.g., 100), which is rejected by IOS.

Forgetting to specify the VLAN ID, causing the command to apply to all VLANs (if supported) or fail.

Setting priority on a switch that already has a lower priority elsewhere, not changing root election.

spanning-tree vlan [id] priority [value] vs spanning-tree vlan [id] root primary

Both commands influence the root bridge election in STP, but they differ in mechanism and flexibility. 'spanning-tree vlan [id] priority [value]' allows explicit priority setting, while 'spanning-tree vlan [id] root primary' automatically adjusts priority to guarantee root status.

Aspectspanning-tree vlan [id] priority [value]spanning-tree vlan [id] root primary
ScopeSets explicit priority value for a VLAN.Automatically sets priority to 24576 or lower to ensure root.
Configuration modeGlobal ConfigurationGlobal Configuration
PersistenceValue remains until changed manually.Priority set at configuration time; does not dynamically adjust to later changes.
PrecedenceExplicit priority overrides dynamic adjustments.Can be overridden by an explicit priority command with a lower value.
Typical useDesignating a specific priority for custom topology control.Quickly designate a switch as root without calculating priority values.

Use spanning-tree vlan [id] priority [value] when you need precise control over the bridge priority value for a VLAN, such as setting it to a specific number for deterministic behavior.

Use spanning-tree vlan [id] root primary when you want to ensure this switch becomes the root bridge for a VLAN without manually calculating the required priority.

Platform Notes

In IOS-XE (e.g., Catalyst 9000 series), the command syntax is identical to classic IOS. However, the output of `show spanning-tree` may include additional fields like 'Operational' status for MST instances. In NX-OS (e.g., Nexus switches), the equivalent command is `spanning-tree vlan [id] priority [value]` but must be entered in configuration mode under the VLAN context: `configure terminal`, `vlan [id]`, `spanning-tree priority [value]`.

Alternatively, you can use `spanning-tree vlan [id] priority [value]` globally, but NX-OS prefers the VLAN context. NX-OS also supports MST with `spanning-tree mst [instance] priority [value]`. For ASA firewalls, STP is not typically configured; they use different redundancy mechanisms.

In IOS-XR, STP is not supported; instead, use MSTP or REP (Resilient Ethernet Protocol). The command does not exist in IOS-XR. In older IOS versions (12.x), the priority value must be a multiple of 4096; setting a non-multiple value would be rejected.

In 15.x and later, the command accepts any value but rounds down to the nearest multiple of 4096. The extended system ID feature is enabled by default in all modern IOS versions, so the priority value you set is combined with the VLAN ID to form the bridge ID. For example, priority 4096 for VLAN 10 results in an effective priority of 4096 + 10 = 4106.

This is important when comparing bridge IDs across switches.

Related Commands

Practice for the CCNA 200-301

Test your knowledge with practice questions covering all CCNA 200-301 exam domains.

Practice CCNA 200-301 Questions