Spanning-Tree Protocols · Topic 3 of 3

Spanning Tree Security

Protect spanning tree on MX routers for the JNCIS-SP JN0-364: BPDU protection on edge ports, bpdu-block, root protection, loop protection and recovery.

  • 5 min
In a nutshell
  • BPDU protection: bpdu-block-on-edge under rstp, mstp or vstp for edge ports, or protocols layer2-control bpdu-block interface for any port.
  • disable-timeout 10 to 3600 seconds; otherwise clear error bpdu interface.
  • Disabled port shows BPDU Error: Detected in show interfaces.

What it is

Spanning tree trusts every BPDU it receives. A customer switch, a misconfigured host or an attacker can send BPDUs that steal the root role, and a one-way link that loses BPDUs can turn a blocked port into a forwarding loop.

Junos OS has three protections that each guard against one of these failures: BPDU protection for ports that should never see a BPDU, root protection for ports that must never become the root port, and loop protection for ports that must not start forwarding just because BPDUs stopped.

BPDU on host portBPDU protectionPort disabledSuperior BPDU on customer portroot protectionRoot preventedblockedBPDUs stop on blocked portloop protectionLoop inconsistentblocked

How it works

Comparing the three protections

BPDU protectionRoot protectionLoop protection
Protects againstAny BPDU on a port facing hostsA downstream bridge becoming rootA blocked port forwarding after BPDUs stop
Use onEdge ports, host-facing portsDesignated ports facing customers or access bridgesNon-designated ports: root and alternate
TriggerA BPDU is receivedA superior BPDU is receivedNo BPDU within the timeout
ResultInterface disabledPort moved to root-prevented, blockingPort moved to loop-inconsistent, blocking
Recoverydisable-timeout or clear error bpdu interfaceAutomatic once superior BPDUs stopAutomatic once BPDUs arrive again

BPDU protection

There are two ways to configure it on an MX.

For ports already marked as edge ports in a spanning tree protocol, enable bpdu-block-on-edge:

user@mx# set protocols rstp interface ge-1/0/5 edge
user@mx# set protocols rstp bpdu-block-on-edge

Without it, an edge port that receives a BPDU simply loses its edge status and takes part in spanning tree. With it, the port is disabled.

For any interface, whether or not spanning tree runs on it, use layer2-control:

user@mx# set protocols layer2-control bpdu-block interface ge-1/0/6
user@mx# set protocols layer2-control bpdu-block disable-timeout 300

The disable-timeout range is 10 to 3600 seconds. Without it, or with 0, the interface stays disabled until an operator clears it:

user@mx> show interfaces ge-1/0/6
user@mx> clear error bpdu interface ge-1/0/6

show interfaces reports BPDU Error: Detected on a disabled port. Clearing the error does not remove the configuration, so if BPDUs keep arriving the port is disabled again.

Exam tip

BPDU protection is the right tool on a UNI where the customer should send data but no spanning tree. It stops a customer's switch from joining your tree at all.

Root protection

Root protection keeps a port designated. If a superior BPDU arrives, one that would make this port the root port, the port moves to the root-prevented state and blocks, for every instance on that interface that receives superior BPDUs.

user@mx# set protocols rstp interface ge-1/0/2 no-root-port

The same no-root-port statement is available under mstp and vstp interfaces. When the superior BPDUs stop, the port returns to normal on its own. Use it where the network design says the root must stay on your side, such as links toward customer or access bridges.

Loop protection

A non-designated port stays blocked because it keeps hearing better BPDUs. If those BPDUs stop, because of a unidirectional link or a stuck neighbor, the port would normally become designated and start forwarding, creating a loop. Loop protection moves it to loop-inconsistent instead.

user@mx# set protocols rstp interface ge-1/0/3 bpdu-timeout-action block

The action is block or log. show spanning-tree interface marks an affected port with Loop-Incon, and the port recovers as soon as BPDUs arrive again. Configure it only on root and alternate ports, not on both ends of a designated link.

Alternate portBPDUs stopTimeoutbpdu timeout action blockLoop inconsistentBPDUs returnAlternate port

Choosing where each goes

A typical provider access ring uses all three: BPDU protection on customer UNIs that should carry no spanning tree, root protection on designated ports toward downstream bridges, and loop protection on the alternate and root ports in the ring.

Common mistakes

Expecting edge alone to block BPDUs. An edge port that receives a BPDU just becomes a normal port. bpdu-block-on-edge or bpdu-block is needed to disable it.

Using root protection on the root port. no-root-port blocks any port that tries to become root port, so placing it on your uplink toward the real root isolates the bridge.

Waiting for root or loop protection to need a clear command. Both recover by themselves when the BPDU condition ends. Only BPDU protection disables a port until a timeout or clear error bpdu.

Watch out

Loop protection belongs on non-designated ports. On both ends of a designated link, certain priority changes can leave both ports blocked.

What to remember for the exam

  • BPDU protection: bpdu-block-on-edge under rstp, mstp or vstp for edge ports, or protocols layer2-control bpdu-block interface for any port.
  • disable-timeout 10 to 3600 seconds; otherwise clear error bpdu interface.
  • Disabled port shows BPDU Error: Detected in show interfaces.
  • Root protection: no-root-port; superior BPDU puts the port in root-prevented; recovers automatically.
  • Loop protection: bpdu-timeout-action block or log; loop-inconsistent; recovers when BPDUs return.
  • Root protection on designated ports; loop protection on root and alternate ports.

Check yourself

  • A host-facing edge port with no protection configured receives a BPDU. What happens?

    It loses its edge status and takes part in spanning tree; it is disabled only if bpdu-block-on-edge or bpdu-block is configured.

  • Which statement stops a customer bridge with a lower priority from becoming root through ge-1/0/2?

    no-root-port on ge-1/0/2 under the spanning tree protocol, which puts the port in the root-prevented state when superior BPDUs arrive.

  • A port disabled by layer2-control bpdu-block with no disable-timeout must be restored. What command do you use?

    clear error bpdu interface followed by the interface name, after removing the source of the BPDUs.

Topic 3 of 3 in Spanning-Tree Protocols

Test yourself on Spanning-Tree Protocols

The full Juniper JNCIS-SP JN0-364 question bank has 860 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.