Spanning Tree · Topic 3 of 3
Configuring and Troubleshooting STP and RSTP
Configure and troubleshoot STP and RSTP on Junos: bridge priority, port cost, edge ports, force-version and the show spanning-tree commands.
- 6 min
- RSTP is the default on EX switches; configure it under
protocols rstp, and STP underprotocols stp. bridge-priority 4kand similar values in steps of 4096; lowest wins; default 32768.- Port statements:
cost,priority(default 128),edge,mode.
What it is
Spanning tree on a Junos switch is configured under the [edit protocols] hierarchy. RSTP is enabled in the factory default configuration of EX switches, so a switch that keeps that default still protects against loops. Configuration is needed to choose the root bridge on purpose, to tune ports and to select classic STP where required.
The work follows one pattern: pick the protocol, set the bridge priority so the right switch is root, mark host ports as edge ports, and verify the result.
How it works
Configuring RSTP
user@switch# set protocols rstp bridge-priority 4k
user@switch# set protocols rstp interface ge-0/0/1
user@switch# set protocols rstp interface ge-0/0/24 cost 1000
user@switch# set protocols rstp interface ge-0/0/5 edge
The same configuration as hierarchy:
protocols {
rstp {
bridge-priority 4k;
interface ge-0/0/1;
interface ge-0/0/5 {
edge;
}
interface ge-0/0/24 {
cost 1000;
}
}
}
| Statement | Effect |
|---|---|
bridge-priority 4k | Sets the bridge priority, here 4096; lower wins the root election |
interface NAME | Runs the protocol on that port |
cost N | Overrides the default speed based port cost |
priority N | Sets the port priority, default 128; lower is better |
edge | Treats the port as an edge port that goes to forwarding at once |
mode point-to-point or mode shared | Sets the link type |
hello-time, forward-delay, max-age | Sets timers; defaults 2, 15 and 20 seconds |
disable | Turns the protocol off for the port or for the whole instance |
Only the root bridge's timers matter, because the root's values are carried in its BPDUs and the other switches adopt them.
To make a switch the root, give it a lower priority than every other switch. A common design sets the planned root to 4k and the planned backup root to 8k.
Configuring STP
Classic STP uses the same statements under protocols stp.
user@switch# set protocols stp bridge-priority 8k
user@switch# set protocols stp interface ge-0/0/1
Do not run STP and RSTP as separate protocols at the same time for the same purpose. Pick one. To keep RSTP configured but make it act as STP, add force-version stp.
user@switch# set protocols rstp force-version stp
Use show | compare before committing. It lists exactly which priority, cost or edge statements the pending change adds, so a change on the wrong switch or port is caught before it takes effect.
Monitoring
| Command | Shows |
|---|---|
show spanning-tree bridge | Root ID, own bridge ID, timers and topology change count |
show spanning-tree interface | Role, state, cost and designated bridge for each port |
show spanning-tree statistics interface ge-0/0/1 | BPDUs sent and received |
show configuration protocols rstp | The committed configuration |
user@switch> show spanning-tree bridge
STP bridge parameters
Context ID : 0
Enabled protocol : RSTP
Root ID : 4096.00:11:22:33:44:55
Root cost : 20000
Root port : ge-0/0/24
Hello time : 2 seconds
Maximum age : 20 seconds
Forward delay : 15 seconds
Message age : 1
Number of topology changes : 3
Time since last topology change : 842 seconds
Local parameters
Bridge ID : 8192.aa:bb:cc:dd:ee:ff
If the Root ID differs from the Bridge ID, the switch is not the root. If they are the same, it is.
user@switch> show spanning-tree interface
Interface Port ID Designated Designated Port State Role
port ID bridge ID Cost
ge-0/0/1 128:2 128:2 8192.aabbccddeeff 20000 FWD DESG
ge-0/0/24 128:25 128:7 4096.001122334455 20000 FWD ROOT
ge-0/0/23 128:24 128:8 4096.001122334455 20000 BLK ALT
Read it row by row: ROOT is the root port, DESG is designated, ALT and BKUP are alternate and backup, and BLK marks a discarding port. The designated bridge ID on the root port row is the root bridge's ID when the neighbor is the root itself.
Troubleshooting
- Wrong root bridge. Compare
Root IDwith the intended switch. Lower the intended root's priority, and check no other switch has a lower one. - Port blocked unexpectedly. Look at the role in
show spanning-tree interface. AnALTorBKUPport is correct, and it forwards again when the active path fails. - Frequent topology changes. A rising count in
show spanning-tree bridgepoints to a flapping link or host ports that are not edge ports. - Slow convergence. A neighbor may run STP, or a link may be shared or half duplex, and the port falls back to the slow timers. Check the link type and the neighbor's protocol.
- No BPDUs seen. Check that the port is listed under the protocol and is not disabled, and that a trunk is up.
The edge setting on a port toward another switch is a mistake. An edge port goes to forwarding without a handshake, and a loop through it can form until BPDUs arrive and the port changes its role.
Common mistakes
Leaving the default priority. Everyone has 32768, and the lowest MAC address wins. The root may then be the worst switch.
Using a priority that is not a multiple of 4096. Priority values are written like 4k and 8k, in steps of 4096.
Setting edge on trunks. Only host facing ports should be edge ports.
Reading show spanning-tree interface wrongly. The Role column is the role and the State column is the state. BLK is the state, not a role.
What to remember for the exam
- RSTP is the default on EX switches; configure it under
protocols rstp, and STP underprotocols stp. bridge-priority 4kand similar values in steps of 4096; lowest wins; default 32768.- Port statements:
cost,priority(default 128),edge,mode. - Default timers: hello 2, forward delay 15, max age 20 seconds.
- Root's timers are the ones in effect for the network.
show spanning-tree bridgeshows the root;show spanning-tree interfaceshows roles and states.force-version stpmakes an RSTP switch behave as STP.
Check yourself
How do you make a Junos switch the root bridge for RSTP?
Give it a lower bridge priority than the other switches, for example
set protocols rstp bridge-priority 4k.In
show spanning-tree interfacea port shows stateBLKand roleALT. What does this mean?It is an alternate port in the discarding state, standing by for the root port.
Which statement makes a host port forward immediately?
edgeunder that interface inprotocols rstp.
Topic 3 of 3 in Spanning Tree
Test yourself on Spanning Tree
The full Juniper JNCIS-ENT JN0-352 question bank has 846 questions, with timed practice exams and an explanation for every answer.
This study guide is independent and is not affiliated with, endorsed by, or sponsored by Juniper. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.