Enabling and configuring STP globally

Follow these steps to enable or disable STP and configure STP parameters.

About this task

You can enable STP or STP with one or more parameters enabled.

The parameters can be configured individually by:
  1. Entering the commands in steps 1 and 2
  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. Enable STP globally.
    device(config)# protocol spanning-tree stp
    
    A spanning tree can be disabled by entering the no protocol spanning-tree stp command.
  3. Describe or name the STP.
    device(config-stp)# description stp1
    
    A description is not required.
  4. Specify the bridge priority.
    device(config-stp)# bridge-priority 4096
    
    The bridge with the lowest priority number (highest priority) is designated the root bridge . The range of values is 0 through 61440; values can be set only in increments of 4096. The default priority is 32678.
  5. Specify the bridge forward delay.
    device(config-stp)# forward-delay 20
    
    The forward delay specifies how long an interface remains in the listening and learning states before it begins forwarding all spanning tree instances. The valid range is from 4 through 30 seconds. The default is 15 seconds.
  6. Configure the maximum aging time.
    device(config-stp)# max-age 25
    
    This parameter controls the maximum length of time that passes before an interface saves its BPDU configuration information. You must set the maximum age to be greater than the hello time. The range is 6 through 40 seconds. The default is 20 seconds.
  7. Configure the maximum hello time.
    device(config-stp)# hello-time 8
    
    The hello time determines how often the switch interface broadcasts hello BPDUs to other devices. The default is 2 seconds while the range is from 1 through 10 seconds.
  8. Enable the error disable timeout timer.
    device(config-stp)# error-disable-timeout enable
    
    This parameter enables a timer that brings a port out of the disabled state. By default, the timeout feature is disabled.
  9. Set the error disable timeout timer.
    device(config-stp)# error-disable-timeout interval 60
    
    When enabled the default is 300 seconds and the range is from 10 through 1000000 seconds.
  10. Configure the port channel path cost.
    device(config-stp)# port-channel path-cost custom
    
    Specifying custom means the path cost changes according to the port channel's bandwidth.
  11. Return to privileged EXEC mode.
    device(config-stp)# end
    
  12. 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     DIS   DIS  20000000   128   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
     

    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.

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

STP configuration example

device# configure terminal
device(config)# protocol spanning-tree stp
device(config-stp)# description stpForInterface
device(config-stp)# bridge-priority 4096
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-stp)# port-channel path-cost custom
device(config-stp)# end
device# show spanning-tree brief
device# copy running-config startup-config