Enabling and configuring STP on an interface

Follow these steps to enable STP and STP features on an interface.

Before you begin

Globally enable STP and STP parameters.

About this task

The parameters can be configured individually by:
  1. Entering the commands in steps 1-3
  2. Running the relevant parameter command
  3. Verifying the result
  4. Saving the configuration

For detailed descriptions of the parameters and features, see the sections STP parameters and STP features.

Procedure

  1. Enter global configuration mode.
    device# configure terminal
    
  2. Enter interface configuration mode.
    device(config)# interface ethernet 0/20
    
  3. Enable the interface.
    device(conf-if-eth-0/20)# no shutdown
    
  4. Configure the path cost for spanning tree calculations on the interface.
    device(conf-if-eth-0/20)# spanning-tree cost 10000
    
    The lower the path cost means a greater chance that the interface becomes the root port. The range is 1 through 200000000. The default path cost is assigned as per the port speed.
  5. Enable BPDU guard on the interface.
    device(conf-if-eth-0/20)# spanning-tree port-fast bpdu-guard
    
    BPDU guard removes a node that reflects BPDUs back in the network. It enforces the STP domain borders and keeps the active topology predictable by not allowing any network devices behind a BPDU guard-enabled port to participate in STP.
  6. Configure Root Guard on the interface.
    device(conf-if-eth-0/20)# spanning-tree guard root
    
    Root Guard protects the root bridge from malicious attacks and unintentional misconfigurations where a bridge device that is not intended to be the root bridge becomes the root bridge.
  7. Specify an interface link-type.
    device(conf-if-eth-0/20)# spanning-tree link-type point-to-point
    
    Specifying a point-to-point link enables rapid spanning tree transitions to the forwarding state. Specifying a shared link disables spanning tree rapid transitions. The default setting is point-to-point.
  8. Specify port priority to influence the selection of root or designated ports.
    device(conf-if-eth-0/20)# spanning-tree priority 64
    
    The range is from 0 through 240 in increments of 16. The default value is 128.
  9. Verify the configuration.
      
    device# show spanning-tree brief
    
     Spanning-tree Mode: Spanning Tree Protocol
    
          Root ID      Priority 4096
                       Address 768e.f805.5800
                       Hello Time 8, Max Age 25, Forward Delay 20
    
          Bridge ID    Priority 4096
                       Address 768e.f805.5800
                       Hello Time 8, Max Age 25, Forward Delay 20
    
     Interface    Role  Sts  Cost       Prio  Link-type     Edge
     ------------------------------------------------------------
     Eth 0/2      DES   FWD  2000       128   P2P            No
     Eth 0/20     DES   FWD  1000        64   P2P            No
     Eth 0/25     DIS   DIS  20000000   128   P2P            No
     Eth 0/30     DIS   DIS  20000000   128   P2P            No
     Eth 0/31     DIS   DIS  2000000    128   P2P            No
     
    Note

    Note

    Observe that the settings comply with the formula set out in the STP parameters section, as:

    (2 × (forward delay - 1)) ≥ maximum age ≥ (2 × (hello time + 1))

    or in this case: 38 ≥ 25 ≥ 18

    device# show running-config interface ethernet 0/20 
    interface ethernet 0/20 
    switchport
    switchport mode access
    switchport access val 1
    spanning-tree cost 1000
    spanning-tree guard root
    spanning-tree link-type point-to-point
    spanning-tree portfast bpdu-guard 
    spanning-tree priority 64
    
  10. Save the settings by copying the running configuration to the startup configuration.
    device# copy running-config startup-config
    

STP on an interface configuration example

device# configure terminal
device(config)# interface ethernet 0/20
device(conf-if-eth-0/20)# no shutdown
device(conf-if-eth-0/20)# spanning-tree cost 10000
device(conf-if-eth-0/20)# spanning-tree port-fast bpdu-guard
device(conf-if-eth-0/20)# spanning-tree guard root
device(conf-if-eth-0/20)# spanning-tree link-type point-to-point
device(conf-if-eth-0/20)# spanning-tree priority 64
device(conf-if-eth-0/20)# end
device# show spanning-tree brief
device# copy running-config startup-config