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.
spanning-tree cost [value]When to Use This Command
- Influencing the root port selection by manually setting a lower cost on a preferred link.
- Forcing traffic to take a specific path in a redundant network by adjusting costs.
- Load balancing across multiple links by setting equal costs for equal-cost paths.
- Troubleshooting suboptimal STP topology by increasing cost on a less desirable link.
Command Examples
Setting a custom port cost on an interface
spanning-tree cost 19No output is generated upon successful configuration. The command sets the STP cost to 19 for the current interface, overriding the default cost (e.g., 100 Mbps default cost is 19).
Verifying the configured cost
show spanning-tree interface gigabitethernet 0/1Vlan Role Sts Cost Prio.Nbr Type ------------------- ---- --- --------- -------- ---------------------------- VLAN0001 Desg FWD 19 128.1 P2p VLAN0010 Desg FWD 19 128.1 P2p
The 'Cost' column shows the configured cost of 19 for both VLANs. 'Desg' indicates the interface is a designated port, 'FWD' means forwarding state, 'Prio.Nbr' shows priority and port number, and 'Type' indicates point-to-point link.
Understanding the Output
When using 'show spanning-tree interface', the output displays per-VLAN STP information. The 'Cost' field shows the port cost used in STP calculations. A lower cost makes the port more likely to be selected as root port. Default costs are based on interface speed: 10 Mbps = 100, 100 Mbps = 19, 1 Gbps = 4, 10 Gbps = 2. Manually set costs override defaults. In a stable network, all ports should be in forwarding (FWD) or blocking (BLK) state. Watch for unexpected costs that could cause suboptimal paths or loops.
CCNA Exam Tips
Remember default costs: 10Mbps=100, 100Mbps=19, 1Gbps=4, 10Gbps=2.
The 'spanning-tree cost' command is configured in interface configuration mode.
CCNA may test that manually set costs override default costs and influence root port selection.
Be able to interpret 'show spanning-tree' output to identify root ports and designated ports based on cost.
Common Mistakes
Setting the cost on the wrong interface (e.g., on an access port instead of trunk).
Forgetting that cost is per-VLAN; if PVST+ is used, cost applies to all VLANs on that interface.
Using too low a cost that causes unexpected root port changes or instability.
Related Commands
Practice for the CCNA 200-301
Test your knowledge with hundreds of CCNA practice questions covering all exam domains.
Practice CCNA Questions