Configuring Spanning Tree Protocol

Finding Feature Information

Your software release may not support all the features documented in this module. For the latest feature information and caveats, see the release notes for your platform and software release.

Use Cisco Feature Navigator to find information about platform support and Cisco software image support. To access Cisco Feature Navigator, go to http:/​/​www.cisco.com/​go/​cfn. An account on Cisco.com is not required.

Restrictions for STP

  • An attempt to configure a switch as the root switch fails if the value necessary to be the root switch is less than 1.
  • If your network consists of switches that support and do not support the extended system ID, it is unlikely that the switch with the extended system ID support will become the root switch. The extended system ID increases the switch priority value every time the VLAN number is greater than the priority of the connected switches running older software.
  • The root switch for each spanning-tree instance should be a backbone or distribution switch. Do not configure an access switch as the spanning-tree primary root.
  • You cannot have a switch stack containing a mix of Catalyst 3850 and Catalyst 3650 switches.
Related Concepts
Bridge ID, Device Priority, and Extended System ID
Spanning-Tree Topology and BPDUs
Accelerated Aging to Retain Connectivity
Related Tasks
Configuring the Root Switch

Information About Spanning Tree Protocol

Spanning Tree Protocol

Spanning Tree Protocol (STP) is a Layer 2 link management protocol that provides path redundancy while preventing loops in the network. For a Layer 2 Ethernet network to function properly, only one active path can exist between any two stations. Multiple active paths among end stations cause loops in the network. If a loop exists in the network, end stations might receive duplicate messages. Switches might also learn end-station MAC addresses on multiple Layer 2 interfaces. These conditions result in an unstable network. Spanning-tree operation is transparent to end stations, which cannot detect whether they are connected to a single LAN segment or a switched LAN of multiple segments.

The STP uses a spanning-tree algorithm to select one switch of a redundantly connected network as the root of the spanning tree. The algorithm calculates the best loop-free path through a switched Layer 2 network by assigning a role to each port based on the role of the port in the active topology:

  • Root—A forwarding port elected for the spanning-tree topology
  • Designated—A forwarding port elected for every switched LAN segment
  • Alternate—A blocked port providing an alternate path to the root bridge in the spanning tree
  • Backup—A blocked port in a loopback configuration

The switch that has all of its ports as the designated role or as the backup role is the root switch. The switch that has at least one of its ports in the designated role is called the designated switch.

Spanning tree forces redundant data paths into a standby (blocked) state. If a network segment in the spanning tree fails and a redundant path exists, the spanning-tree algorithm recalculates the spanning-tree topology and activates the standby path. Switches send and receive spanning-tree frames, called bridge protocol data units (BPDUs), at regular intervals. The switches do not forward these frames but use them to construct a loop-free path. BPDUs contain information about the sending switch and its ports, including switch and MAC addresses, switch priority, port priority, and path cost. Spanning tree uses this information to elect the root switch and root port for the switched network and the root port and designated port for each switched segment.

When two ports on a switch are part of a loop, the spanning-tree and path cost settings control which port is put in the forwarding state and which is put in the blocking state. The spanning-tree port priority value represents the location of a port in the network topology and how well it is located to pass traffic. The path cost value represents the media speed.


Note


By default, the switch sends keepalive messages (to ensure the connection is up) only on interfaces that do not have small form-factor pluggable (SFP) modules. You can change the default for an interface by entering the [ no] keepalive interface configuration command with no keywords.


Spanning-Tree Topology and BPDUs

The stable, active spanning-tree topology of a switched network is controlled by these elements:

  • The unique bridge ID (switch priority and MAC address) associated with each VLAN on each switch. In a switch stack, all switches use the same bridge ID for a given spanning-tree instance.
  • The spanning-tree path cost to the root switch.
  • The port identifier (port priority and MAC address) associated with each Layer 2 interface.

When the switches in a network are powered up, each functions as the root switch. Each switch sends a configuration BPDU through all of its ports. The BPDUs communicate and compute the spanning-tree topology. Each configuration BPDU contains this information:

  • The unique bridge ID of the switch that the sending switch identifies as the root switch
  • The spanning-tree path cost to the root
  • The bridge ID of the sending switch
  • Message age
  • The identifier of the sending interface
  • Values for the hello, forward delay, and max-age protocol timers

When a switch receives a configuration BPDU that contains superior information (lower bridge ID, lower path cost, and so forth), it stores the information for that port. If this BPDU is received on the root port of the switch, the switch also forwards it with an updated message to all attached LANs for which it is the designated switch.

If a switch receives a configuration BPDU that contains inferior information to that currently stored for that port, it discards the BPDU. If the switch is a designated switch for the LAN from which the inferior BPDU was received, it sends that LAN a BPDU containing the up-to-date information stored for that port. In this way, inferior information is discarded, and superior information is propagated on the network.

A BPDU exchange results in these actions:

  • One switch in the network is elected as the root switch (the logical center of the spanning-tree topology in a switched network). See the figure following the bullets. For each VLAN, the switch with the highest switch priority (the lowest numerical priority value) is elected as the root switch. If all switches are configured with the default priority (32768), the switch with the lowest MAC address in the VLAN becomes the root switch. The switch priority value occupies the most significant bits of the bridge ID, as shown in the following figure.
  • A root port is selected for each switch (except the root switch). This port provides the best path (lowest cost) when the switch forwards packets to the root switch. When selecting the root port on a switch stack, spanning tree follows this sequence:
    • Selects the lowest root bridge ID
    • Selects the lowest path cost to the root switch
    • Selects the lowest designated bridge ID
    • Selects the lowest designated path cost
    • Selects the lowest port ID
  • Only one outgoing port on the stack root switch is selected as the root port. The remaining switches in the stack become its designated switches (Switch 2 and Switch 3) as shown in the following figure.
  • The shortest distance to the root switch is calculated for each switch based on the path cost.
  • A designated switch for each LAN segment is selected. The designated switch incurs the lowest path cost when forwarding packets from that LAN to the root switch. The port through which the designated switch is attached to the LAN is called the designated port.
Figure 1. Spanning-Tree Port States in a Switch Stack. One stack member is elected as the stack root switch. The stack root switch contains the outgoing root port (Switch 1).

All paths that are not needed to reach the root switch from anywhere in the switched network are placed in the spanning-tree blocking mode.

Related Tasks
Configuring the Root Switch
Related References
Restrictions for STP

Bridge ID, Device Priority, and Extended System ID

The IEEE 802.1D standard requires that each switch has an unique bridge identifier (bridge ID), which controls the selection of the root switch. Because each VLAN is considered as a different logical bridge with PVST+ and Rapid PVST+, the same switch must have a different bridge ID for each configured VLAN. Each VLAN on the switch has a unique 8-byte bridge ID. The 2 most-significant bytes are used for the switch priority, and the remaining 6 bytes are derived from the switch MAC address.

The switch supports the IEEE 802.1t spanning-tree extensions, and some of the bits previously used for the switch priority are now used as the VLAN identifier. The result is that fewer MAC addresses are reserved for the switch, and a larger range of VLAN IDs can be supported, all while maintaining the uniqueness of the bridge ID.

The 2 bytes previously used for the switch priority are reallocated into a 4-bit priority value and a 12-bit extended system ID value equal to the VLAN ID.

Table 1 Device Priority Value and Extended System ID

Priority Value

Extended System ID (Set Equal to the VLAN ID)

Bit 16

Bit 15

Bit 14

Bit 13

Bit 12

Bit 11

Bit 10

Bit 9

Bit 8

Bit 7

Bit 6

Bit 5

Bit 4

Bit 3

Bit 2

Bit 1

32768

16384

8192

4096

2048

1024

512

256

128

64

32

16

8

4

2

1

Spanning tree uses the extended system ID, the switch priority, and the allocated spanning-tree MAC address to make the bridge ID unique for each VLAN. Because the switch stack appears as a single switch to the rest of the network, all switches in the stack use the same bridge ID for a given spanning tree. If the stack master fails, the stack members recalculate their bridge IDs of all running spanning trees based on the new MAC address of the new stack master.

Support for the extended system ID affects how you manually configure the root switch, the secondary root switch, and the switch priority of a VLAN. For example, when you change the switch priority value, you change the probability that the switch will be elected as the root switch. Configuring a higher value decreases the probability; a lower value increases the probability.

If any root switch for the specified VLAN has a switch priority lower than 24576, the switch sets its own priority for the specified VLAN to 4096 less than the lowest switch priority. 4096 is the value of the least-significant bit of a 4-bit switch priority value as shown in the table.

Related Concepts
Root Switch
Related Tasks
Configuring the Root Switch
Configuring the Root Switch
Specifying the MST Region Configuration and Enabling MSTP
Related References
Restrictions for STP

Port Priority Versus Path Cost

If a loop occurs, spanning tree uses port priority when selecting an interface to put into the forwarding state. You can assign higher priority values (lower numerical values) to interfaces that you want selected first and lower priority values (higher numerical values) that you want selected last. If all interfaces have the same priority value, spanning tree puts the interface with the lowest interface number in the forwarding state and blocks the other interfaces.

The spanning-tree path cost default value is derived from the media speed of an interface. If a loop occurs, spanning tree uses cost when selecting an interface to put in the forwarding state. You can assign lower cost values to interfaces that you want selected first and higher cost values that you want selected last. If all interfaces have the same cost value, spanning tree puts the interface with the lowest interface number in the forwarding state and blocks the other interfaces.

If your switch is a member of a switch stack, you must assign lower cost values to interfaces that you want selected first and higher cost values that you want selected last instead of adjusting its port priority. For details, see Related Topics.

Related Tasks
Configuring Port Priority
Configuring Path Cost

Spanning-Tree Interface States

Propagation delays can occur when protocol information passes through a switched LAN. As a result, topology changes can take place at different times and at different places in a switched network. When an interface transitions directly from nonparticipation in the spanning-tree topology to the forwarding state, it can create temporary data loops. Interfaces must wait for new topology information to propagate through the switched LAN before starting to forward frames. They must allow the frame lifetime to expire for forwarded frames that have used the old topology.

Each Layer 2 interface on a switch using spanning tree exists in one of these states:

  • Blocking—The interface does not participate in frame forwarding.
  • Listening—The first transitional state after the blocking state when the spanning tree decides that the interface should participate in frame forwarding.
  • Learning—The interface prepares to participate in frame forwarding.
  • Forwarding—The interface forwards frames.
  • Disabled—The interface is not participating in spanning tree because of a shutdown port, no link on the port, or no spanning-tree instance running on the port.

An interface moves through these states:

  • From initialization to blocking
  • From blocking to listening or to disabled
  • From listening to learning or to disabled
  • From learning to forwarding or to disabled
  • From forwarding to disabled
Figure 2. Spanning-Tree Interface States. An interface moves through the states.

When you power up the switch, spanning tree is enabled by default, and every interface in the switch, VLAN, or network goes through the blocking state and the transitory states of listening and learning. Spanning tree stabilizes each interface at the forwarding or blocking state.

When the spanning-tree algorithm places a Layer 2 interface in the forwarding state, this process occurs:

  1. The interface is in the listening state while spanning tree waits for protocol information to move the interface to the blocking state.
  2. While spanning tree waits for the forward-delay timer to expire, it moves the interface to the learning state and resets the forward-delay timer.
  3. In the learning state, the interface continues to block frame forwarding as the switch learns end-station location information for the forwarding database.
  4. When the forward-delay timer expires, spanning tree moves the interface to the forwarding state, where both learning and frame forwarding are enabled.

Blocking State

A Layer 2 interface in the blocking state does not participate in frame forwarding. After initialization, a BPDU is sent to each switch interface. A switch initially functions as the root until it exchanges BPDUs with other switches. This exchange establishes which switch in the network is the root or root switch. If there is only one switch in the network, no exchange occurs, the forward-delay timer expires, and the interface moves to the listening state. An interface always enters the blocking state after switch initialization.

An interface in the blocking state performs these functions:

  • Discards frames received on the interface
  • Discards frames switched from another interface for forwarding
  • Does not learn addresses
  • Receives BPDUs

Listening State

The listening state is the first state a Layer 2 interface enters after the blocking state. The interface enters this state when the spanning tree decides that the interface should participate in frame forwarding.

An interface in the listening state performs these functions:

  • Discards frames received on the interface
  • Discards frames switched from another interface for forwarding
  • Does not learn addresses
  • Receives BPDUs

Learning State

A Layer 2 interface in the learning state prepares to participate in frame forwarding. The interface enters the learning state from the listening state.

An interface in the learning state performs these functions:

  • Discards frames received on the interface
  • Discards frames switched from another interface for forwarding
  • Learns addresses
  • Receives BPDUs

Forwarding State

A Layer 2 interface in the forwarding state forwards frames. The interface enters the forwarding state from the learning state.

An interface in the forwarding state performs these functions:

  • Receives and forwards frames received on the interface
  • Forwards frames switched from another interface
  • Learns addresses
  • Receives BPDUs

Disabled State

A Layer 2 interface in the disabled state does not participate in frame forwarding or in the spanning tree. An interface in the disabled state is nonoperational.

A disabled interface performs these functions:

  • Discards frames received on the interface
  • Discards frames switched from another interface for forwarding
  • Does not learn addresses
  • Does not receive BPDUs

How a Switch or Port Becomes the Root Switch or Root Port

If all switches in a network are enabled with default spanning-tree settings, the switch with the lowest MAC address becomes the root switch.

Figure 3. Spanning-Tree Topology. Switch A is elected as the root switch because the switch priority of all the switches is set to the default (32768) and Switch A has the lowest MAC address. However, because of traffic patterns, number of forwarding interfaces, or link types, Switch A might not be the ideal root switch. By increasing the priority (lowering the numerical value) of the ideal switch so that it becomes the root switch, you force a spanning-tree recalculation to form a new topology with the ideal switch as the root.

When the spanning-tree topology is calculated based on default parameters, the path between source and destination end stations in a switched network might not be ideal. For instance, connecting higher-speed links to an interface that has a higher number than the root port can cause a root-port change. The goal is to make the fastest link the root port.

For example, assume that one port on Switch B is a Gigabit Ethernet link and that another port on Switch B (a 10/100 link) is the root port. Network traffic might be more efficient over the Gigabit Ethernet link. By changing the spanning-tree port priority on the Gigabit Ethernet port to a higher priority (lower numerical value) than the root port, the Gigabit Ethernet port becomes the new root port.

Related Tasks
Configuring Port Priority

Spanning Tree and Redundant Connectivity

Figure 4. Spanning Tree and Redundant Connectivity. You can create a redundant backbone with spanning tree by connecting two switch interfaces to another device or to two different devices. Spanning tree automatically disables one interface but enables it if the other one fails. If one link is high-speed and the other is low-speed, the low-speed link is always disabled. If the speeds are the same, the port priority and port ID are added together, and spanning tree disables the link with the lowest value.

You can also create redundant links between switches by using EtherChannel groups.

Spanning-Tree Address Management

IEEE 802.1D specifies 17 multicast addresses, ranging from 0x00180C2000000 to 0x0180C2000010, to be used by different bridge protocols. These addresses are static addresses that cannot be removed.

Regardless of the spanning-tree state, each switch in the stack receives but does not forward packets destined for addresses between 0x0180C2000000 and 0x0180C200000F.

If spanning tree is enabled, the CPU on the switch or on each switch in the stack receives packets destined for 0x0180C2000000 and 0x0180C2000010. If spanning tree is disabled, the switch or each switch in the stack forwards those packets as unknown multicast addresses.

Accelerated Aging to Retain Connectivity

The default for aging dynamic addresses is 5 minutes, the default setting of the mac address-table aging-time global configuration command. However, a spanning-tree reconfiguration can cause many station locations to change. Because these stations could be unreachable for 5 minutes or more during a reconfiguration, the address-aging time is accelerated so that station addresses can be dropped from the address table and then relearned. The accelerated aging is the same as the forward-delay parameter value ( spanning-tree vlan vlan-id forward-time seconds global configuration command) when the spanning tree reconfigures.

Because each VLAN is a separate spanning-tree instance, the switch accelerates aging on a per-VLAN basis. A spanning-tree reconfiguration on one VLAN can cause the dynamic addresses learned on that VLAN to be subject to accelerated aging. Dynamic addresses on other VLANs can be unaffected and remain subject to the aging interval entered for the switch.

Related Tasks
Configuring the Root Switch
Related References
Restrictions for STP

Spanning-Tree Modes and Protocols

The switch supports these spanning-tree modes and protocols:

  • PVST+—This spanning-tree mode is based on the IEEE 802.1D standard and Cisco proprietary extensions. It is the default spanning-tree mode used on all Ethernet port-based VLANs. The PVST+ runs on each VLAN on the switch up to the maximum supported, ensuring that each has a loop-free path through the network. The PVST+ provides Layer 2 load-balancing for the VLAN on which it runs. You can create different logical topologies by using the VLANs on your network to ensure that all of your links are used but that no one link is oversubscribed. Each instance of PVST+ on a VLAN has a single root switch. This root switch propagates the spanning-tree information associated with that VLAN to all other switches in the network. Because each switch has the same information about the network, this process ensures that the network topology is maintained.
  • Rapid PVST+—This spanning-tree mode is the same as PVST+ except that is uses a rapid convergence based on the IEEE 802.1w standard. To provide rapid convergence, the Rapid PVST+ immediately deletes dynamically learned MAC address entries on a per-port basis upon receiving a topology change. By contrast, PVST+ uses a short aging time for dynamically learned MAC address entries. Rapid PVST+ uses the same configuration as PVST+ (except where noted), and the switch needs only minimal extra configuration. The benefit of Rapid PVST+ is that you can migrate a large PVST+ install base to Rapid PVST+ without having to learn the complexities of the Multiple Spanning Tree Protocol (MSTP) configuration and without having to reprovision your network. In Rapid PVST+ mode, each VLAN runs its own spanning-tree instance up to the maximum supported.
  • MSTP—This spanning-tree mode is based on the IEEE 802.1s standard. You can map multiple VLANs to the same spanning-tree instance, which reduces the number of spanning-tree instances required to support a large number of VLANs. The MSTP runs on top of the RSTP (based on IEEE 802.1w), which provides for rapid convergence of the spanning tree by eliminating the forward delay and by quickly transitioning root ports and designated ports to the forwarding state. In a switch stack, the cross-stack rapid transition (CSRT) feature performs the same function as RSTP. You cannot run MSTP without RSTP or CSRT.
Related Tasks
Changing the Spanning-Tree Mode

Supported Spanning-Tree Instances

In PVST+ or Rapid PVST+ mode, the switch or switch stack supports up to 128 spanning-tree instances.

In MSTP mode, the switch or switch stack supports up to 65 MST instances. The number of VLANs that can be mapped to a particular MST instance is unlimited.

Related Concepts
Default Spanning-Tree Configuration
Default MSTP Configuration
Related Tasks
Disabling Spanning Tree

Spanning-Tree Interoperability and Backward Compatibility

In a mixed MSTP and PVST+ network, the common spanning-tree (CST) root must be inside the MST backbone, and a PVST+ switch cannot connect to multiple MST regions.

When a network contains switches running Rapid PVST+ and switches running PVST+, we recommend that the Rapid PVST+ switches and PVST+ switches be configured for different spanning-tree instances. In the Rapid PVST+ spanning-tree instances, the root switch must be a Rapid PVST+ switch. In the PVST+ instances, the root switch must be a PVST+ switch. The PVST+ switches should be at the edge of the network.

All stack members run the same version of spanning tree (all PVST+, all Rapid PVST+, or all MSTP).



Table 2 PVST+, MSTP, and Rapid-PVST+ Interoperability and Compatibility
 

PVST+

MSTP

Rapid PVST+

PVST+

Yes

Yes (with restrictions)

Yes (reverts to PVST+)

MSTP

Yes (with restrictions)

Yes

Yes (reverts to PVST+)

Rapid PVST+

Yes (reverts to PVST+)

Yes (reverts to PVST+)

Yes

Related Concepts
MSTP Configuration Guidelines
Multiple Spanning-Tree Regions
Related Tasks
Specifying the MST Region Configuration and Enabling MSTP

STP and IEEE 802.1Q Trunks

The IEEE 802.1Q standard for VLAN trunks imposes some limitations on the spanning-tree strategy for a network. The standard requires only one spanning-tree instance for all VLANs allowed on the trunks. However, in a network of Cisco switches connected through IEEE 802.1Q trunks, the switches maintain one spanning-tree instance for each VLAN allowed on the trunks.

When you connect a Cisco switch to a non-Cisco device through an IEEE 802.1Q trunk, the Cisco switch uses PVST+ to provide spanning-tree interoperability. If Rapid PVST+ is enabled, the switch uses it instead of PVST+. The switch combines the spanning-tree instance of the IEEE 802.1Q VLAN of the trunk with the spanning-tree instance of the non-Cisco IEEE 802.1Q switch.

However, all PVST+ or Rapid PVST+ information is maintained by Cisco switches separated by a cloud of non-Cisco IEEE 802.1Q switches. The non-Cisco IEEE 802.1Q cloud separating the Cisco switches is treated as a single trunk link between the switches.

PVST+ is automatically enabled on IEEE 802.1Q trunks, and no user configuration is required. The external spanning-tree behavior on access ports and Inter-Switch Link (ISL) trunk ports is not affected by PVST+.

VLAN-Bridge Spanning Tree

Cisco VLAN-bridge spanning tree is used with the fallback bridging feature (bridge groups), which forwards non-IP protocols such as DECnet between two or more VLAN bridge domains or routed ports. The VLAN-bridge spanning tree allows the bridge groups to form a spanning tree on top of the individual VLAN spanning trees to prevent loops from forming if there are multiple connections among VLANs. It also prevents the individual spanning trees from the VLANs being bridged from collapsing into a single spanning tree.

To support VLAN-bridge spanning tree, some of the spanning-tree timers are increased. To use the fallback bridging feature, you must have the IP services feature set enabled on your switch.

Spanning Tree and Switch Stacks

When the switch stack is operating in PVST+ or Rapid PVST+ mode:

  • A switch stack appears as a single spanning-tree node to the rest of the network, and all stack members use the same bridge ID for a given spanning tree. The bridge ID is derived from the MAC address of the active switch.
  • When a new switch joins the stack, it sets its bridge ID to the active switch bridge ID. If the newly added switch has the lowest ID and if the root path cost is the same among all stack members, the newly added switch becomes the stack root.
  • When a stack member leaves the stack, spanning-tree reconvergence occurs within the stack (and possibly outside the stack). The remaining stack member with the lowest stack port ID becomes the stack root.
  • If the switch stack is the spanning-tree root and the active switch fails or leaves the stack, the standby switch becomes the new active switch, bridge IDs remain the same, and a spanning-tree reconvergence might occur.
  • If a neighboring switch external to the switch stack fails or is powered down, normal spanning-tree processing occurs. Spanning-tree reconvergence might occur as a result of losing a switch in the active topology.
  • If a new switch external to the switch stack is added to the network, normal spanning-tree processing occurs. Spanning-tree reconvergence might occur as a result of adding a switch in the network.

Default Spanning-Tree Configuration

Table 3 Default Spanning-Tree Configuration

Feature

Default Setting

Enable state

Enabled on VLAN 1.

Spanning-tree mode

PVST+. (Rapid PVST+ and MSTP are disabled.)

Switch priority

32768

Spanning-tree port priority (configurable on a per-interface basis)

128

Spanning-tree port cost (configurable on a per-interface basis)

1000 Mb/s: 4

100 Mb/s: 19

10 Mb/s: 100

Spanning-tree VLAN port priority (configurable on a per-VLAN basis)

128

Spanning-tree VLAN port cost (configurable on a per-VLAN basis)

1000 Mb/s: 4

100 Mb/s: 19

10 Mb/s: 100

Spanning-tree timers

Hello time: 2 seconds

Forward-delay time: 15 seconds

Maximum-aging time: 20 seconds

Transmit hold count: 6 BPDUs

Related Tasks
Disabling Spanning Tree
Related References
Supported Spanning-Tree Instances

How to Configure Spanning-Tree Features

Changing the Spanning-Tree Mode

The switch supports three spanning-tree modes: per-VLAN spanning tree plus (PVST+), Rapid PVST+, or multiple spanning tree protocol (MSTP). By default, the switch runs the PVST+ protocol.

If you want to enable a mode that is different from the default mode, this procedure is required.

Beginning in privileged EXEC mode, follow these steps to change the spanning-tree mode:

SUMMARY STEPS

    1.    configure terminal

    2.    spanning-tree mode { pvst | mst | rapid-pvst}

    3.    interface interface-id

    4.    spanning-tree link-type point-to-point

    5.    end

    6.    clear spanning-tree detected-protocols


DETAILED STEPS
      Command or Action Purpose
    Step 1 configure terminal


    Example:
    
                
                
    Switch# configure terminal
    
    
     

    Enters the global configuration mode.

     
    Step 2 spanning-tree mode { pvst | mst | rapid-pvst}


    Example:
    
                
                
    Switch(config)# spanning-tree mode pvst
    
     

    Configures a spanning-tree mode. All stack members run the same version of spanning tree.

    • Select pvst to enable PVST+ (the default setting).
    • Select mst to enable MSTP (and RSTP).
    • Select rapid-pvst to enable rapid PVST+.
     
    Step 3 interface interface-id


    Example:
    
                
                
    Switch(config)# interface GigabitEthernet1/0/1
    
     

    (Recommended for Rapid PVST+ mode only) Specifies an interface to configure, and enters interface configuration mode. Valid interfaces include physical ports, VLANs, and port channels. The VLAN ID range is 1 to 4094. The port-channel range is 1 to 48.

     
    Step 4 spanning-tree link-type point-to-point


    Example:
    
                
                
    Switch(config-if)# spanning-tree link-type point-to-point
    
     

    (Recommended for Rapid PVST+ mode only) Specifies that the link type for this port is point-to-point.

    If you connect this port (local port) to a remote port through a point-to-point link and the local port becomes a designated port, the switch negotiates with the remote port and rapidly changes the local port to the forwarding state.

     
    Step 5 end


    Example:
    
                
                
    Switch(config-if)# end
    
     

    Returns to privileged EXEC mode.

     
    Step 6 clear spanning-tree detected-protocols


    Example:
    
                
                
    Switch# clear spanning-tree detected-protocols
    
     

    (Recommended for Rapid PVST+ mode only) If any port on the switch is connected to a port on a legacy IEEE 802.1D switch, this command restarts the protocol migration process on the entire switch.

    This step is optional if the designated switch detects that this switch is running rapid PVST+.

     
    Related References
    Spanning-Tree Modes and Protocols

    Disabling Spanning Tree

    Spanning tree is enabled by default on VLAN 1 and on all newly created VLANs up to the spanning-tree limit. Disable spanning tree only if you are sure there are no loops in the network topology.


    Caution


    When spanning tree is disabled and loops are present in the topology, excessive traffic and indefinite packet duplication can drastically reduce network performance.


    This procedure is optional.

    Beginning in privileged EXEC mode, follow these steps to disable a spanning tree:

    SUMMARY STEPS

      1.    configure terminal

      2.    no spanning-tree vlan vlan-id

      3.    end


    DETAILED STEPS
        Command or Action Purpose
      Step 1 configure terminal


      Example:
      
                  
                  
      Switch# configure terminal
      
      
       

      Enters the global configuration mode.

       
      Step 2 no spanning-tree vlan vlan-id


      Example:
      
                  
                  
      Switch(config)# no spanning-tree vlan 300
      
       

      For vlan-id, the range is 1 to 4094.

       
      Step 3 end


      Example:
      
                  
                  
      Switch(config)# end
      
      
       

      Returns to privileged EXEC mode.

       
      Related Concepts
      Default Spanning-Tree Configuration
      Related References
      Supported Spanning-Tree Instances

      Configuring the Root Switch

      To configure a switch as the root for the specified VLAN, use the spanning-tree vlan vlan-id root global configuration command to modify the switch priority from the default value (32768) to a significantly lower value. When you enter this command, the software checks the switch priority of the root switches for each VLAN. Because of the extended system ID support, the switch sets its own priority for the specified VLAN to 24576 if this value will cause this switch to become the root for the specified VLAN.

      Use the diameter keyword to specify the Layer 2 network diameter (that is, the maximum number of switch hops between any two end stations in the Layer 2 network). When you specify the network diameter, the switch automatically sets an optimal hello time, forward-delay time, and maximum-age time for a network of that diameter, which can significantly reduce the convergence time. You can use the hello keyword to override the automatically calculated hello time.

      This procedure is optional.

      Beginning in privileged EXEC mode, follow these steps to configure a switch to become the root for the specified VLAN:

      SUMMARY STEPS

        1.    configure terminal

        2.    spanning-tree vlan vlan-id root primary [ diameter net-diameter ]

        3.    end


      DETAILED STEPS
          Command or Action Purpose
        Step 1 configure terminal


        Example:
        
                    
                    
        Switch# configure terminal
        
        
         

        Enters the global configuration mode.

         
        Step 2 spanning-tree vlan vlan-id root primary [ diameter net-diameter ]


        Example:
        
                    
                    
        Switch(config)# spanning-tree vlan 20-24 root primary diameter 4
        
         

        Configures a switch to become the root for the specified VLAN.

        • For vlan-id, you can specify a single VLAN identified by VLAN ID number, a range of VLANs separated by a hyphen, or a series of VLANs separated by a comma. The range is 1 to 4094.
        • (Optional) For diameter net-diameter, specify the maximum number of switches between any two end stations. The range is 2 to 7.
         
        Step 3 end


        Example:
        
                    
                    
        Switch(config)# end
        
        
         

        Returns to privileged EXEC mode.

         
        What to Do Next

        After configuring the switch as the root switch, we recommend that you avoid manually configuring the hello time, forward-delay time, and maximum-age time through the spanning-tree vlan vlan-id hello-time, spanning-tree vlan vlan-id forward-time, and the spanning-tree vlan vlan-id max-age global configuration commands.

        Related Concepts
        Bridge ID, Device Priority, and Extended System ID
        Spanning-Tree Topology and BPDUs
        Accelerated Aging to Retain Connectivity
        Related References
        Restrictions for STP

        Configuring a Secondary Root Device

        When you configure a switch as the secondary root, the switch priority is modified from the default value (32768) to 28672. With this priority, the switch is likely to become the root switch for the specified VLAN if the primary root switch fails. This is assuming that the other network switches use the default switch priority of 32768, and therefore, are unlikely to become the root switch.

        You can execute this command on more than one switch to configure multiple backup root switches. Use the same network diameter and hello-time values that you used when you configured the primary root switch with the spanning-tree vlan vlan-id root primary global configuration command.

        This procedure is optional.

        Beginning in privileged EXEC mode, follow these steps to configure a switch to become a secondary root for the specified VLAN:

        SUMMARY STEPS

          1.    configure terminal

          2.    spanning-tree vlan vlan-id root secondary [ diameter net-diameter]

          3.    end


        DETAILED STEPS
            Command or Action Purpose
          Step 1 configure terminal


          Example:
          
                      
                      
          Switch# configure terminal
          
          
           

          Enters the global configuration mode.

           
          Step 2 spanning-tree vlan vlan-id root secondary [ diameter net-diameter]


          Example:
          
                      
                      
          Switch(config)# spanning-tree vlan 20-24 root secondary diameter 4
          
           

          Configures a switch to become the secondary root for the specified VLAN.

          • For vlan-id, you can specify a single VLAN identified by VLAN ID number, a range of VLANs separated by a hyphen, or a series of VLANs separated by a comma. The range is 1 to 4094.
          • (Optional) For diameter net-diameter, specify the maximum number of switches between any two end stations. The range is 2 to 7.

          Use the same network diameter value that you used when configuring the primary root switch.

           
          Step 3 end


          Example:
          
                      
                      
          Switch(config)# end
          
          
           

          Returns to privileged EXEC mode.

           

          Configuring Port Priority


          Note


          If your switch is a member of a switch stack, you must use the spanning-tree [ vlan vlan-id] cost cost interface configuration command instead of the spanning-tree [ vlan vlan-id] port-priority priority interface configuration command to select an interface to put in the forwarding state. Assign lower cost values to interfaces that you want selected first and higher cost values that you want selected last.


          This procedure is optional.

          Beginning in privileged EXEC mode, follow these steps to configure port priority:

          SUMMARY STEPS

            1.    configure terminal

            2.    interface interface-id

            3.    spanning-tree port-priority priority

            4.    spanning-tree vlan vlan-id port-priority priority

            5.    end


          DETAILED STEPS
              Command or Action Purpose
            Step 1 configure terminal


            Example:
            
                        
                        
            Switch# configure terminal
            
            
             

            Enters the global configuration mode.

             
            Step 2 interface interface-id


            Example:
            
                        
                        
            Switch(config)# interface gigabitethernet1/0/2
            
             

            Specifies an interface to configure, and enters interface configuration mode.

            Valid interfaces include physical ports and port-channel logical interfaces ( port-channel port-channel-number).

             
            Step 3 spanning-tree port-priority priority


            Example:
            
                        
                        
            Switch(config-if)# spanning-tree port-priority 0
            
             

            Configures the port priority for an interface.

            For priority, the range is 0 to 240, in increments of 16; the default is 128. Valid values are 0, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192, 208, 224, and 240. All other values are rejected. The lower the number, the higher the priority.

             
            Step 4 spanning-tree vlan vlan-id port-priority priority


            Example:
            
                        
                        
            Switch(config-if)# spanning-tree vlan 20-25 port-priority 0
            
             

            Configures the port priority for a VLAN.

            • For vlan-id, you can specify a single VLAN identified by VLAN ID number, a range of VLANs separated by a hyphen, or a series of VLANs separated by a comma. The range is 1 to 4094.
            • For priority, the range is 0 to 240, in increments of 16; the default is 128. Valid values are 0, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192, 208, 224, and 240. All other values are rejected. The lower the number, the higher the priority.
             
            Step 5 end


            Example:
            
                        
                        
            Switch(config-if)# end
            
             

            Returns to privileged EXEC mode.

             
            Related Concepts
            Port Priority Versus Path Cost
            How a Switch or Port Becomes the Root Switch or Root Port

            Configuring Path Cost

            This procedure is optional.

            Beginning in privileged EXEC mode, follow these steps to configure path cost:

            SUMMARY STEPS

              1.    configure terminal

              2.    interface interface-id

              3.    spanning-tree cost cost

              4.    spanning-tree vlan vlan-id cost cost

              5.    end


            DETAILED STEPS
                Command or Action Purpose
              Step 1 configure terminal


              Example:
              
                          
                          
              Switch# configure terminal
              
              
               

              Enters the global configuration mode.

               
              Step 2 interface interface-id


              Example:
              
                          
                          
              Switch(config)# interface gigabitethernet1/0/1
              
               

              Specifies an interface to configure, and enters interface configuration mode. Valid interfaces include physical ports and port-channel logical interfaces ( port-channel port-channel-number).

               
              Step 3 spanning-tree cost cost


              Example:
              
                          
                          
              Switch(config-if)# spanning-tree cost 250
              
               

              Configures the cost for an interface.

              If a loop occurs, spanning tree uses the path cost when selecting an interface to place into the forwarding state. A lower path cost represents higher-speed transmission.

              For cost, the range is 1 to 200000000; the default value is derived from the media speed of the interface.

               
              Step 4 spanning-tree vlan vlan-id cost cost


              Example:
              
                          
                          
              Switch(config-if)# spanning-tree vlan 10,12-15,20 cost 300
              
               

              Configures the cost for a VLAN.

              If a loop occurs, spanning tree uses the path cost when selecting an interface to place into the forwarding state. A lower path cost represents higher-speed transmission.

              • For vlan-id, you can specify a single VLAN identified by VLAN ID number, a range of VLANs separated by a hyphen, or a series of VLANs separated by a comma. The range is 1 to 4094.
              • For cost, the range is 1 to 200000000; the default value is derived from the media speed of the interface.
               
              Step 5 end


              Example:
              
                          
                          
              Switch(config-if)# end
              
               

              Returns to privileged EXEC mode.

               

              The show spanning-tree interface interface-id privileged EXEC command displays information only for ports that are in a link-up operative state. Otherwise, you can use the show running-config privileged EXEC command to confirm the configuration.

              Related Concepts
              Port Priority Versus Path Cost

              Configuring the Device Priority of a VLAN

              You can configure the switch priority and make it more likely that a standalone switch or a switch in the stack will be chosen as the root switch.


              Note


              Exercise care when using this command. For most situations, we recommend that you use the spanning-tree vlan vlan-id root primary and the spanning-tree vlan vlan-id root secondary global configuration commands to modify the switch priority.


              This procedure is optional. Beginning in privileged EXEC mode, follow these steps to configure the switch priority of a VLAN:

              SUMMARY STEPS

                1.    configure terminal

                2.    spanning-tree vlan vlan-id priority priority

                3.    end


              DETAILED STEPS
                  Command or Action Purpose
                Step 1 configure terminal


                Example:
                
                            
                            
                Switch# configure terminal
                
                
                 

                Enters the global configuration mode.

                 
                Step 2 spanning-tree vlan vlan-id priority priority


                Example:
                
                            
                            
                Switch(config)# spanning-tree vlan 20 priority 8192
                
                 

                Configures the switch priority of a VLAN.

                • For vlan-id, you can specify a single VLAN identified by VLAN ID number, a range of VLANs separated by a hyphen, or a series of VLANs separated by a comma. The range is 1 to 4094.
                • For priority, the range is 0 to 61440 in increments of 4096; the default is 32768. The lower the number, the more likely the switch will be chosen as the root switch. Valid priority values are 4096, 8192, 12288, 16384, 20480, 24576, 28672, 32768, 36864, 40960, 45056, 49152, 53248, 57344, and 61440. All other values are rejected.
                 
                Step 3 end


                Example:
                
                            
                            
                Switch(config-if)# end
                
                 

                Returns to privileged EXEC mode.

                 

                Configuring the Hello Time

                The hello time is the time interval between configuration messages generated and sent by the root switch.

                This procedure is optional.

                Beginning in privileged EXEC mode, follow these steps to configure hello time:

                SUMMARY STEPS

                  1.    spanning-tree vlan vlan-id hello-time seconds

                  2.    end


                DETAILED STEPS
                    Command or Action Purpose
                  Step 1 spanning-tree vlan vlan-id hello-time seconds


                  Example:
                  
                              
                              
                  Switch(config)# spanning-tree vlan 20-24 hello-time 3
                  
                   

                  Configures the hello time of a VLAN. The hello time is the time interval between configuration messages generated and sent by the root switch. These messages mean that the switch is alive.

                  • For vlan-id, you can specify a single VLAN identified by VLAN ID number, a range of VLANs separated by a hyphen, or a series of VLANs separated by a comma. The range is 1 to 4094.
                  • For seconds, the range is 1 to 10; the default is 2.
                   
                  Step 2 end


                  Example:
                  
                              
                              
                  Switch(config-if)# end
                  
                   

                  Returns to privileged EXEC mode.

                   

                  Configuring the Forwarding-Delay Time for a VLAN

                  This procedure is optional.

                  Beginning in privileged EXEC mode, follow these steps to configure the forwarding delay time for a VLAN:

                  SUMMARY STEPS

                    1.    configure terminal

                    2.    spanning-tree vlan vlan-id forward-time seconds

                    3.    end


                  DETAILED STEPS
                      Command or Action Purpose
                    Step 1 configure terminal


                    Example:
                    
                                
                                
                    Switch# configure terminal
                    
                    
                     

                    Enters the global configuration mode.

                     
                    Step 2 spanning-tree vlan vlan-id forward-time seconds


                    Example:
                    
                                
                                
                    Switch(config)# spanning-tree vlan 20,25 forward-time 18
                    
                     

                    Configures the forward time of a VLAN. The forwarding delay is the number of seconds an interface waits before changing from its spanning-tree learning and listening states to the forwarding state.

                    • For vlan-id, you can specify a single VLAN identified by VLAN ID number, a range of VLANs separated by a hyphen, or a series of VLANs separated by a comma. The range is 1 to 4094.
                    • For seconds, the range is 4 to 30; the default is 15.
                     
                    Step 3 end


                    Example:
                    
                                
                                
                    Switch(config)# end
                    
                    
                     

                    Returns to privileged EXEC mode.

                     

                    Configuring the Maximum-Aging Time for a VLAN

                    This procedure is optional.

                    Beginning in privileged EXEC mode, follow these steps to configure the maximum-aging time for a VLAN:

                    SUMMARY STEPS

                      1.    configure terminal

                      2.    spanning-tree vlan vlan-id max-age seconds

                      3.    end


                    DETAILED STEPS
                        Command or Action Purpose
                      Step 1 configure terminal


                      Example:
                      
                                  
                                  
                      Switch# configure terminal
                      
                      
                       

                      Enters the global configuration mode.

                       
                      Step 2 spanning-tree vlan vlan-id max-age seconds


                      Example:
                      
                                  
                                  
                      Switch(config)# spanning-tree vlan 20 max-age 30
                      
                       

                      Configures the maximum-aging time of a VLAN. The maximum-aging time is the number of seconds a switch waits without receiving spanning-tree configuration messages before attempting a reconfiguration.

                      • For vlan-id, you can specify a single VLAN identified by VLAN ID number, a range of VLANs separated by a hyphen, or a series of VLANs separated by a comma. The range is 1 to 4094.
                      • For seconds, the range is 6 to 40; the default is 20.
                       
                      Step 3 end


                      Example:
                      
                                  
                                  
                      Switch(config-if)# end
                      
                       

                      Returns to privileged EXEC mode.

                       

                      Configuring the Transmit Hold-Count

                      You can configure the BPDU burst size by changing the transmit hold count value.


                      Note


                      Changing this parameter to a higher value can have a significant impact on CPU utilization, especially in Rapid PVST+ mode. Lowering this value can slow down convergence in certain scenarios. We recommend that you maintain the default setting.


                      This procedure is optional.

                      Beginning in privileged EXEC mode, follow these steps to configure transmit hold-count:

                      SUMMARY STEPS

                        1.    configure terminal

                        2.    spanning-tree transmit hold-count value

                        3.    end


                      DETAILED STEPS
                          Command or Action Purpose
                        Step 1 configure terminal


                        Example:
                        
                                    
                                    
                        Switch# configure terminal
                        
                        
                         

                        Enters the global configuration mode.

                         
                        Step 2 spanning-tree transmit hold-count value


                        Example:
                        
                                    
                                    
                        Switch(config)# spanning-tree transmit hold-count 6
                        
                         

                        Configures the number of BPDUs that can be sent before pausing for 1 second.

                        For value, the range is 1 to 20; the default is 6.

                         
                        Step 3 end


                        Example:
                        
                                    
                                    
                        Switch(config)# end
                        
                        
                         

                        Returns to privileged EXEC mode.

                         

                        Monitoring Spanning-Tree Status

                        Table 4 Commands for Displaying Spanning-Tree Status
                           

                        show spanning-tree active

                        Displays spanning-tree information on active interfaces only.

                        show spanning-tree detail

                        Displays a detailed summary of interface information.

                        show spanning-tree vlan vlan-id

                        Displays spanning-tree information for the specified VLAN.

                        show spanning-tree interface interface-id

                        Displays spanning-tree information for the specified interface.

                        show spanning-tree interface interface-id portfast

                        Displays spanning-tree portfast information for the specified interface.

                        show spanning-tree summary [ totals]

                        Displays a summary of interface states or displays the total lines of the STP state section.

                        To clear spanning-tree counters, use the clear spanning-tree [ interface i nterface-id] privileged EXEC command.

                        Additional References for Spanning-Tree Protocol

                        Related Documents

                        Related Topic Document Title

                        Spanning tree protocol commands

                        LAN Switching Command Reference, Cisco IOS XE Release 3SE (Catalyst 3850 Switches)

                        Error Message Decoder

                        Description Link

                        To help you research and resolve system error messages in this release, use the Error Message Decoder tool.

                        https:/​/​www.cisco.com/​cgi-bin/​Support/​Errordecoder/​index.cgi

                        Standards and RFCs

                        Standard/RFC Title
                        None

                        MIBs

                        MIB MIBs Link

                        All supported MIBs for this release.

                        To locate and download MIBs for selected platforms, Cisco IOS releases, and feature sets, use Cisco MIB Locator found at the following URL:

                        http:/​/​www.cisco.com/​go/​mibs

                        Technical Assistance

                        Description Link

                        The Cisco Support website provides extensive online resources, including documentation and tools for troubleshooting and resolving technical issues with Cisco products and technologies.

                        To receive security and technical information about your products, you can subscribe to various services, such as the Product Alert Tool (accessed from Field Notices), the Cisco Technical Services Newsletter, and Really Simple Syndication (RSS) Feeds.

                        Access to most tools on the Cisco Support website requires a Cisco.com user ID and password.

                        http:/​/​www.cisco.com/​support

                        Feature Information for STP

                        Release

                        Modification

                        Cisco IOS XE 3.2SE

                        This feature was introduced.