Back to Command Reference
Global ConfigDomain 5.0

spanning-tree vlan [id] root [primary/secondary]

A powerful IOS macro command used to rig the Spanning Tree Protocol (STP) election. Instead of manually guessing what Bridge Priority number to assign, this command inspects the network, calculates the current Root Bridge's priority, and automatically lowers the local switch's priority to guarantee it wins the election.

Quick Reference

Execution ModeSwitch(config)#
Underlying MechanismAlters the Bridge Priority value.
Default Priority32768 (+ VLAN ID)
Manual Alternativespanning-tree vlan [id] priority [value]

Syntax Breakdown

spanning-tree vlan [id] root [primary | secondary]
Role OptionMacro Calculation Behavior
primaryThe switch checks the current Root Bridge's priority.
• If the current root is sitting at the default 32768, this switch sets its own priority to 24576.
• If another switch has already lowered its priority, this switch will calculate a priority that is exactly 4096 less than the current root to steal the crown.
secondaryDesignates the switch as the backup Root Bridge. It hardcodes the local priority to 28672. This ensures it will beat all default switches (32768), but still lose to the primary root (24576).

CLI Deployment Scenarios

Scenario 1: Securing the Core Architecture

You have a powerful Multilayer Core Switch. You must guarantee it becomes the center of the spanning tree so all traffic flows efficiently through the high-speed backplane.

Switch(config)# spanning-tree vlan 1,10,20 root primary
! The switch instantly lowers its priority to 24576 for VLANs 1, 10, and 20.
! It broadcasts superior BPDUs, and all other switches block links pointing away from this core.

Scenario 2: The Manual Priority Override

Instead of using the macro, you want to absolutely guarantee a switch remains the root bridge forever by hardcoding the lowest mathematically possible priority value.

Switch(config)# spanning-tree vlan 10 priority 0
! The priority is set to 0. It is impossible for any other switch to beat this value.

CCNA Exam Gotchas

[!]

The 4096 Multiplier Rule

If an exam question asks you to manually set a spanning-tree priority, the value must be an exact multiple of 4096 (0, 4096, 8192, 12288, 16384, etc.). If you try to type spanning-tree vlan 10 priority 100, the CLI will reject it. This is because the other 12 bits in the 16-bit priority header are reserved for the System Extended ID (the VLAN number).

[!]

Preemption is Automatic

Unlike routing protocols (like HSRP) where you have to explicitly configure preemption, Spanning Tree preempts automatically. The moment a switch powers on with a superior (lower) priority, it instantly forces a network recalculation and steals the Root Bridge role.