Spanning Tree
RSTP by default, VSTP per VLAN
On EX and QFX, RSTP (802.1w) is the usual choice: enable it with set protocols rstp interface all or per interface. RSTP computes one topology that serves every VLAN. When you need a different topology per VLAN for load sharing, VSTP runs an independent 802.1w instance for each VLAN (set protocols vstp vlan 10 interface all); MSTP maps groups of VLANs onto instances. Running RSTP and VSTP at the same time on the same port is a conflict.
Election and port roles
Root election uses the lowest bridge ID: priority plus MAC. Priority is configured in steps of 4096 (default 32768), so bridge-priority 4096 beats the default and a tie is broken by the lower MAC. Ports take the roles root, designated, alternate, or backup, and move through discarding, learning, and forwarding. An edge port (set protocols rstp interface ge-0/0/5 edge) skips the learning delay and should face hosts only; combined with bpdu-block-on-edge it err-disables if a BPDU appears, which is the standard defence against a user looping the network. no-root-port acts as root guard, stopping a port from becoming the root direction. Junos default path costs are 100 (10 Mbps), 19 (100 Mbps), 4 (1 Gbps), and 2 (10 Gbps).
Traps
- Forgetting that STP must be enabled per interface, or that RSTP does not build per-VLAN topologies.
- Placing
edgeon a switch-to-switch link, which invites loops. - Assuming the DR-style preemption rules of other protocols: RSTP does re-elect when a better bridge ID appears.
Worked example
SW1 has bridge-priority 4096, SW2 keeps 32768, so SW1 is root regardless of MAC. If both used 4096, the lower MAC wins - which is why predictable designs set an explicit low priority on the intended core switch.