Configuring basic STP parameters

Follow this example to configure basic STP behavior.

  1. Enter global configuration mode.
    device# configure terminal
    
  2. Enable STP globally
    device(config)# protocol spanning-tree stp
    
  3. Name the STP.
    device(config-stp)# description stp1
    
  4. Designate the root switch.
    device(conf-stp)# bridge-priority 28672
    
    The priority values can be set only in increments of 4096. The range is 0 through 61440.
  5. Specify the bridge forward delay.
    device(config-stp)# forward-delay 20
    
  6. Configure the maximum aging time.
    device(config-stp)# max-age 25
    
  7. Configure the maximum hello time.
    device(config-stp)# hello-time 8
    
  8. Enable the error disable timeout timer.
    device(config-stp)# error-disable-timeout enable
    
  9. Set the error disable timeout timer interval.
    device(config-stp)# error-disable-timeout interval 60
    
  10. Enable port fast on switch ports.
    1. Configure port fast on Ethernet port 0/1.
      device(config)# interface ethernet 0/1
      device(conf-if-eth-0/1)# spanning-tree portfast
      device(conf-if-eth-0/1)# exit
      
      Spanning trees are automatically enabled on switch ports.
    2. Configure port fast on Ethernet port 0/2.
      device(config)# interface ethernet 0/2
      device(conf-if-eth-0/2)# spanning-tree portfast
      device(conf-if-eth-0/2)# exit
      
    3. Repeat these commands for every port connected to workstations or PCs.
      device(config)# interface ethernet ...
      
  11. Specify port priorities to influence the selection of the root and designated ports.
    device(config)# interface ethernet 0/1
    device(conf-if-eth-0/1)# spanning-tree priority 1 
    device(conf-if-eth-0/1)# exit
    
  12. Enable the guard root feature.
    device(config)# interface ethernet 0/12
    device(conf-if-eth-0/12)# no shutdown
    device(conf-if-eth-0/12)# spanning-tree guard root
    
    Root guard lets the device top participate in the STP but only when the device does not attempt to become the root.
  13. Return to privileged exec mode.
    device(conf-if-eth-0/12)# end
    
  14. 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/1       DES      FWD     2000     128      P2P           No
    Eth 0/2       DES      FWD     2000     128      P2P           No
    Eth 0/12      DES      FWD     2000     128      P2P           No
    
    Observe that the settings comply with the formula set out in the STP parameter configuration section, as:

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

    or in this case 38 ≥ 25 ≥ 18.

  15. Save the configuration.
    device# copy running-config startup-config
    

Basic STP configuration example

device# configure terminal
device(config)# protocol spanning-tree stp
device(config-stp)# description stp1
device(conf-stp)# bridge-priority 28672
device(config-stp)# forward-delay 20
device(config-stp)# max-age 25
device(config-stp)# hello-time 8
device(config-stp)# error-disable-timeout enable
device(config-stp)# error-disable-timeout interval 60
device(config)# interface ethernet 0/1
device(conf-if-eth-0/1)# spanning-tree portfast
device(conf-if-eth-0/1)# exit
device(config)# interface ethernet 0/2
device(conf-if-eth-0/2)# spanning-tree portfast
device(conf-if-eth-0/2)# exit
device(config)# interface ethernet 0/1
device(conf-if-eth-0/1)# spanning-tree priority 1 
device(conf-if-eth-0/1)# exit
device(config)# interface ethernet 0/12
device(conf-if-eth-0/12)# no shutdown
device(conf-if-eth-0/12)# spanning-tree guard root
device(conf-if-eth-0/12)# end
device# show spanning-tree brief
device# copy running-config startup-config