Courseiva
Spanning TreeGlobal Config

spanning-tree vlan [id] root primary

This command configures a switch as the root bridge for a specific VLAN by setting its bridge priority to 24576 (or lower if another switch has a lower priority), ensuring it becomes the root bridge in the Spanning Tree Protocol (STP) topology.

Definition: spanning-tree vlan [id] root primary is a Cisco IOS global config command. This command configures a switch as the root bridge for a specific VLAN by setting its bridge priority to 24576 (or lower if another switch has a lower priority), ensuring it becomes the root bridge in the Spanning Tree Protocol (STP) topology.

Overview

The `spanning-tree vlan [id] root primary` command is a critical tool for network engineers configuring Spanning Tree Protocol (STP) in multi-switch environments. Its primary purpose is to designate a specific switch as the root bridge for a given VLAN, ensuring deterministic Layer 2 topology and preventing loops. By setting the bridge priority to 24576 (or lower if another switch already has a priority lower than 24576), this command forces the switch to become the root bridge, assuming no other switch has a priority lower than 24576.

This is essential in networks where traffic patterns must be optimized, such as when a particular switch has superior hardware or is centrally located to minimize latency. The command is typically used during initial STP design or when troubleshooting suboptimal path selection. Alternatives include manually setting the bridge priority with `spanning-tree vlan [id] priority [value]`, which offers finer control but requires knowledge of the current root bridge priority.

The `root primary` command simplifies this by automatically adjusting the priority to a value that ensures root status, making it ideal for quick deployments. It fits into the broader workflow of STP configuration, often preceded by VLAN creation and followed by verification with `show spanning-tree`. Important IOS behaviors: the command modifies the running configuration immediately, requires global configuration mode (privilege level 15), and does not generate buffered output.

It is supported in IOS 12.x and later, with no impact on other VLANs unless specified. Understanding this command is fundamental for CCNA and CCNP candidates, as it directly influences network stability and performance.

Syntax·Global Config
spanning-tree vlan [id] root primary

When to Use This Command

  • When designing a redundant network, you want a specific core switch to be the root bridge for VLAN 10 to control the STP topology and prevent suboptimal paths.
  • After adding a new switch to the network, you need to force a particular switch to become the root bridge for VLAN 20 to maintain consistent traffic flow.
  • During network troubleshooting, you need to manually set the root bridge for VLAN 30 to stabilize STP after a topology change.
  • In a multi-VLAN environment, you want to distribute root bridge roles across different switches for load balancing.

Parameters

ParameterSyntaxDescription
idVLAN ID (1-4094)Specifies the VLAN for which the switch should become the root bridge. Valid values are from 1 to 4094, but VLANs 1002-1005 are reserved for Token Ring and FDDI. Common mistake: using VLAN 0 or a non-existent VLAN ID; ensure the VLAN exists in the VLAN database.

Command Examples

Setting root bridge for VLAN 10

Switch(config)# spanning-tree vlan 10 root primary
Switch(config)#

No output is displayed upon successful execution. The command sets the bridge priority for VLAN 10 to 24576, making this switch the root bridge unless another switch has a priority lower than 24576.

Verifying root bridge status after configuration

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

  Bridge ID  Priority    24576  (priority 24576 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/1            Desg FWD 4         128.1    P2p
Gi0/2            Desg FWD 4         128.2    P2p

The output shows that this bridge is the root for VLAN 10. The Root ID and Bridge ID both have priority 24576 and the same MAC address, confirming root status. Interface roles are 'Desg' (designated) and states are 'FWD' (forwarding).

Understanding the Output

The 'show spanning-tree vlan [id]' command displays STP information for a specific VLAN. The 'Root ID' section shows the 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 system ID extension for the VLAN) and MAC address. Interface details include role (Root, Desg, Altn, Back, etc.) and state (FWD, BLK, LRN, LIS). A healthy STP topology should have one root bridge per VLAN, with all other switches having a root port in forwarding state.

Watch for unexpected root bridges or blocked ports that may indicate misconfiguration.

Configuration Scenarios

Designating a Core Switch as Root Bridge for VLAN 10

In a campus network with multiple access switches, the core switch (SW-Core) should be the root bridge for VLAN 10 to ensure optimal traffic flow between departments. Without this, a less capable access switch might become root, causing suboptimal paths.

Topology

SW-Core(Gi0/1)---trunk---(Gi0/1)SW-Access1 SW-Core(Gi0/2)---trunk---(Gi0/1)SW-Access2

Steps

  1. 1.Step 1: Enter privileged EXEC mode: enable
  2. 2.Step 2: Enter global configuration mode: configure terminal
  3. 3.Step 3: Configure SW-Core as root for VLAN 10: spanning-tree vlan 10 root primary
  4. 4.Step 4: Exit configuration mode: end
  5. 5.Step 5: Verify the root bridge status: show spanning-tree vlan 10
Configuration
!
SW-Core# configure terminal
SW-Core(config)# spanning-tree vlan 10 root primary
SW-Core(config)# end
SW-Core#

Verify: Use `show spanning-tree vlan 10` and look for 'Root ID' showing the MAC address of SW-Core and priority 24576. Expected output snippet: 'Root ID Priority 24576 Address 0011.2233.4455'

Watch out: If another switch already has a priority lower than 24576 (e.g., 8192), the command will set the priority to 4096 (one step below the current root) but may not make this switch the root if the other switch's priority is already lower than 4096. Always verify the current root priority before using this command.

Forcing a Distribution Switch as Root for VLAN 20 in a Redundant Topology

In a network with redundant links between distribution and access layers, the distribution switch (SW-Dist) should be the root for VLAN 20 to prevent loops and ensure predictable failover. The access switches have default priorities (32768), so this command will set SW-Dist to 24576.

Topology

SW-Dist(Gi0/1)---trunk---(Gi0/2)SW-Access SW-Dist(Gi0/2)---trunk---(Gi0/3)SW-Access

Steps

  1. 1.Step 1: Enter privileged EXEC mode: enable
  2. 2.Step 2: Enter global configuration mode: configure terminal
  3. 3.Step 3: Configure SW-Dist as root for VLAN 20: spanning-tree vlan 20 root primary
  4. 4.Step 4: Exit configuration mode: end
  5. 5.Step 5: Verify the root bridge status: show spanning-tree vlan 20
Configuration
!
SW-Dist# configure terminal
SW-Dist(config)# spanning-tree vlan 20 root primary
SW-Dist(config)# end
SW-Dist#

Verify: Use `show spanning-tree vlan 20` and confirm the root bridge is SW-Dist with priority 24576. Also check that all ports are in appropriate states (e.g., designated or root).

Watch out: If the VLAN is not created on the switch, the command will still execute but the switch will not become root until the VLAN is created. Always ensure the VLAN exists with `vlan [id]` before applying this command.

Troubleshooting with This Command

When troubleshooting STP root bridge issues, the `spanning-tree vlan [id] root primary` command is often used reactively after identifying a suboptimal root. Healthy output from `show spanning-tree` shows the intended root bridge with priority 24576 (or lower) and all other switches having higher priorities. Problem indicators include a different switch as root with a priority lower than 24576, or the intended root not appearing in the root ID field.

Focus on the 'Root ID' section: if the priority is not 24576 or lower, the command may have failed due to a lower priority elsewhere. Common symptoms this command helps diagnose include high CPU utilization on an unintended root, asymmetric traffic flows, or frequent TCNs (Topology Change Notifications). A step-by-step diagnostic flow: 1) Identify the current root with `show spanning-tree vlan [id]`; 2) Check the priority of the current root; 3) If the current root is not the desired switch, apply the `root primary` command on the desired switch; 4) Re-verify with `show spanning-tree` to confirm the change; 5) If the desired switch still isn't root, check for a switch with priority lower than 24576 using `show spanning-tree vlan [id]` on all switches; 6) Manually set the priority on the offending switch to a higher value (e.g., 32768) using `spanning-tree vlan [id] priority 32768`.

Correlate this command's output with `show spanning-tree detail` to see timers and port roles, and with `debug spanning-tree events` to monitor topology changes. In large networks, also use `show spanning-tree vlan [id] root` to quickly see the root bridge details. Remember that the command only affects the specified VLAN; other VLANs remain unchanged.

If the network uses MST (Multiple Spanning Tree), the equivalent command is `spanning-tree mst [instance] root primary`. Always ensure consistent STP versions across switches to avoid interoperability issues.

CCNA Exam Tips

1.

CCNA exam tip: The 'spanning-tree vlan [id] root primary' command sets the priority to 24576, but if another switch already has a lower priority, it will set the priority to 4096 less than that switch's priority (minimum 1).

2.

CCNA exam tip: Remember that the root bridge selection is based on lowest bridge priority (priority + VLAN ID). The default priority is 32768, so setting to 24576 ensures it becomes root unless another switch has a priority lower than 24576.

3.

CCNA exam tip: You can also use 'spanning-tree vlan [id] root secondary' to set priority to 28672, making the switch the backup root bridge.

4.

CCNA exam tip: The command does not produce any output on success; always verify with 'show spanning-tree' to confirm root status.

Common Mistakes

Mistake 1: Forgetting to specify the VLAN ID, which causes the command to fail or apply to all VLANs incorrectly.

Mistake 2: Assuming the command immediately changes the root bridge without considering that STP convergence takes time (forward delay).

Mistake 3: Using 'spanning-tree vlan [id] root primary' on a switch that is already the root, which has no effect but may cause confusion.

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

Both spanning-tree vlan root primary and spanning-tree vlan priority are used to influence the root bridge election for a specific VLAN, but they differ in approach. Root primary is a shortcut that dynamically sets the priority to ensure the switch becomes root, while priority gives exact control over the numerical priority value.

Aspectspanning-tree vlan [id] root primaryspanning-tree vlan [id] priority [value]
Configuration complexitySimple; single command auto-selects priorityRequires manual calculation of priority value
Priority value setDynamically sets to 24576 or lower if another bridge has lower prioritySets exact priority value specified by user
PrecedenceIf both configured, last command applied takes effectIf both configured, last command applied takes effect
Typical use caseQuickly designate the switch as root without detailed planningFine-tuning root bridge selection in complex topologies
PersistenceSaved in running-config as 'spanning-tree vlan 10 root primary'Saved in running-config as 'spanning-tree vlan 10 priority 4096' (or other value)

Use spanning-tree vlan [id] root primary when you want a quick, reliable method to ensure the switch becomes the root bridge without calculating exact priority values.

Use spanning-tree vlan [id] priority [value] when you need precise control over the bridge priority, such as when designing a specific STP hierarchy with multiple tiers.

Platform Notes

In IOS-XE (e.g., Catalyst 3650/3850), the command syntax is identical to classic IOS: `spanning-tree vlan [id] root primary`. However, IOS-XE may show additional output fields in `show spanning-tree`, such as 'Operational' priority. The NX-OS equivalent on Nexus switches is `spanning-tree vlan [id] root primary` as well, but NX-OS uses a different default priority (32768) and the command sets the priority to 24576 similarly.

On ASA firewalls, STP is not typically used; instead, ASA uses redundant interfaces or EtherChannel for redundancy. For IOS-XR (e.g., ASR 9000), STP is not supported; instead, use Ethernet OAM or other Layer 2 mechanisms. In older IOS versions (12.x), the command behaves the same but output formats may differ slightly (e.g., no 'Operational' field).

In IOS 15.x and 16.x, the command remains unchanged. Note that on some platforms, the command may require the 'spanning-tree' feature to be enabled globally with `spanning-tree mode [pvst|rapid-pvst|mst]`. Always verify the STP mode before using this command.

For MST, use `spanning-tree mst [instance] root primary` instead. The command is available in all IOS versions that support PVST+ or Rapid PVST+.

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