Hands-On Lab: Configuring Spanning Tree Root Bridges Using the IOS Macro Command

This hands-on lab uses the spanning-tree root primary and root secondary macro commands to configure a primary and backup root bridge without manually calculating priority values, and verifies IOS automatically selects an appropriate priority relative to the current root.

Spanning Tree Root MacroRoot Primary SecondaryAutomatic Priority Calculation

~3 min read · Updated Sep 22, 2026

Lab Objective

Use the root primary and root secondary macro commands to designate one switch as the primary root bridge and a second switch as the backup root, without manually specifying a numeric priority, and verify IOS calculates appropriate values automatically.

Lab Purpose

Manually calculating a priority value low enough to guarantee root status, as done in the previous lab, requires knowing every other switch's current priority in the network. The root primary macro removes this guesswork by having IOS automatically select a priority guaranteed to be lower than the current root's.

Lab Topology

Switch1 (intended primary root)
Switch2 (intended secondary/backup root)
Switch3 (access switch, default priority)

All connected via trunk links in VLAN 1

Task 1: Configure Switch1 as Primary Root

Use the macro command to configure Switch1 as the primary root bridge for VLAN 1.

Task 2: Verify the Automatically Assigned Priority

Check what priority value IOS actually assigned to Switch1.

Task 3: Configure Switch2 as Secondary Root

Use the macro command to configure Switch2 as the secondary (backup) root bridge for VLAN 1.

Task 4: Verify Switch2's Assigned Priority

Check what priority value IOS assigned to Switch2, confirming it is higher than Switch1's but still lower than the default.

Task 5: Confirm Root Bridge Status

Confirm Switch1 is recognized as root by all switches in the topology.

Solution and Verification

Switch1(config)# spanning-tree vlan 1 root primary

Switch1# show spanning-tree vlan 1 | include Priority

Bridge ID  Priority    24576
-- IOS automatically selected 24576, a value
-- guaranteed to be lower than any other
-- switch's current priority at the time this
-- command was issued -- no manual calculation
-- was required

Switch2(config)# spanning-tree vlan 1 root secondary

Switch2# show spanning-tree vlan 1 | include Priority

Bridge ID  Priority    28672
-- IOS assigned 28672 -- lower than the default
-- 32768 (so Switch2 still outranks a plain
-- default-priority switch), but higher than
-- Switch1's 24576, ensuring Switch2 only
-- becomes root if Switch1 fails

Switch1# show spanning-tree vlan 1 | include Root
Root ID    Priority    24576
           This bridge is the root

Switch3# show spanning-tree vlan 1 | include Root
Root ID    Priority    24576
           Root has priority 24576
-- Every switch in the topology correctly
-- agrees Switch1 is root

Key Takeaway

The root primary and root secondary macros calculate an appropriate priority automatically based on the current network state at the moment the command runs, rather than requiring the administrator to survey every switch's existing priority first — but this also means the assigned value is only guaranteed relative to conditions at that exact moment, so a later switch added with an even lower manual priority could still displace the intended root.

Written & researched by Dr. Shahin Siami

Related Articles

Hands-On Lab: Setting Switchports to Dynamic Trunking Modes

This hands-on lab configures switchport dynamic desirable and dynamic auto modes, demonstrating how Dynamic Trunking Protocol automatically negotiates whether a link becomes a trunk or remains an access port, and covers why relying on DTP is generally discouraged in production networks.

Continue

Hands-On Lab: Configuring, Verifying, and Troubleshooting EtherChannel (Static/PAgP/LACP)

This hands-on lab bundles two physical links between switches into a single logical EtherChannel using static, PAgP, and LACP modes in turn, verifies each bundle forms correctly, and demonstrates the mismatched-mode failure that prevents a bundle from forming.

Continue

Hands-On Lab: Enabling Rapid Per-VLAN Spanning Tree (RPVST+)

This hands-on lab migrates a switch from classic PVST+ to Rapid PVST+, comparing the significantly faster convergence time and the updated port role terminology that comes with the newer protocol.

Continue

Hands-On Lab: Configuring Spanning Tree Protocol for Access Ports (PortFast)

This hands-on lab configures PortFast on an access port connecting to an end-user device, bypassing the normal listening and learning delay so the port forwards traffic immediately, and covers why PortFast should never be applied to a port connecting to another switch.

Continue

Hands-On Lab: Assigning Spanning Tree Priority to Multiple VLANs Simultaneously

This hands-on lab configures Spanning Tree bridge priority across several VLANs in a single command using a VLAN range, rather than repeating the configuration individually for each VLAN, and verifies the priority was correctly applied to every VLAN in the range.

Continue

Hands-On Lab: Configuring Spanning Tree Protocol Root Bridges Manually

This hands-on lab manually influences Spanning Tree root bridge election by adjusting bridge priority on two competing switches, verifying which switch becomes root before and after the change, and confirming the resulting port roles update accordingly.

Continue