Tutorials · Switching

How to Prevent Network Loops With Spanning Tree (RSTP)

Stop broadcast storms caused by loops: enable RSTP, choose the root bridge, and protect edge ports with BPDU guard.

Beginner10 min5 steps

Before you start

  • Managed switches supporting 802.1w RSTP or 802.1s MSTP

Step by step

  1. Enable RSTP everywhere

    Use the same mode on every switch.

    spanning-tree mode rstp
    
  2. Make the core switch the root

    Set the lowest priority on the core so the topology is predictable.

    spanning-tree priority 4096
    
  3. Mark edge ports

    Ports to PCs, phones and cameras should start forwarding immediately.

    interface range gigabitEthernet 0/1-24
     spanning-tree portfast
    
  4. Enable BPDU guard

    If someone plugs a switch into a user port, the port shuts down instead of creating a loop.

    interface range gigabitEthernet 0/1-24
     spanning-tree bpduguard enable
    
  5. Verify

    Check the root bridge and port roles.

    show spanning-tree
    

Commands are generic, industry-standard examples. Exact syntax and menu names vary by model and firmware; check your device's manual on the Documentation page.

Pro tips

  • Enable storm control on access ports as a second layer of protection.
  • For rings of industrial switches, ERPS recovers faster than RSTP.
How to Prevent Network Loops With Spanning Tree (RSTP) | Navijin Tutorials