Spanning Tree Protocol (STP) is a critical Layer 2 protocol that prevents network loops while maintaining redundant paths. On Juniper EX and QFX Series switches, proper STP configuration is essential for network stability and reliability.
The protocol works by:
Proper configuration of STP is crucial because:
Example of a loop:[Switch1] ------- [switch2] \ / \ / \ / [ Switch 3 ]
Before implementing STP, it's crucial to:
Choose the appropriate STP variant based on your requirements:
A) Basic STP Configuration Steps
A.1. Enabling STP on the SwitchBy default, RSTP is enabled on EX and QFX switches. If you need to configure traditional STP:[edit protocols]user@switch# delete rstp # First delete RSTPuser@switch# set stp # Enable STP globally
user@switch# delete rstp
user@switch# set stp
For forcing RSTP to run in STP mode (recommended method):[edit protocols]user@switch# set rstp force-version 0 # Forces RSTP to run in STP compatibility mode
[edit protocols]
user@switch# set rstp force-version 0
A.2. Adding Interfaces to STPYou can enable STP on all interfaces or specific interfaces:
For all interfaces:[edit protocols]user@switch# set stp interface all
user@switch# set stp interface all
For specific interfaces:[edit protocols]user@switch# set stp interface ge-0/0/0user@switch# set stp interface ge-0/0/1
user@switch# set stp interface ge-0/0/0
user@switch# set stp interface ge-0/0/1
Configure root bridge priority (optional but suggested):[edit protocols]user@switch# set stp bridge-priority 16k # Lower value increases the chance of becoming the root bridge
user@switch# set stp bridge-priority 16k
A.3. Verifying STP Configuration
Basic configuration verification:user@switch> show configuration protocols stpuser@switch> show spanning-tree bridgeuser@switch> show spanning-tree interface
user@switch> show configuration protocols stp
user@switch> show spanning-tree bridge
user@switch> show spanning-tree interfac
B) Optional Advanced Configurations
1. Edge Port Configuration:[edit protocols]user@switch# set stp interface ge-0/0/10 edge # For ports connected to end devices
user@switch# set stp interface ge-0/0/10 edge # For ports connected to end devices
2. Root Protection:[edit protocols]user@switch# set stp interface ge-0/0/1 root-protection
user@switch# set stp interface ge-0/0/1 root-protection
3. BPDU Protection:[edit protocols]user@switch# set stp interface ge-0/0/2 bpdu-block
user@switch# set stp interface ge-0/0/2 bpdu-block
4. Cost Configuration:[edit protocols]user@switch# set stp interface ge-0/0/3 cost 1000
user@switch# set stp interface ge-0/0/3 cost 1000
2026-06-05: Merge of 2 KBs
2024-02-26 : Article Created
Additional documentation for troubleshooting: