STP Commands

This chapter contains the following sections:

clear spanning-tree detected-protocols

To restart the Spanning Tree Protocol (STP) migration process (force renegotiation with neighboring switches) on all interfaces or on a specific interface, use the clear spanning-tree detected-protocols Interface Configuration mode command.

Syntax

clear spanning-tree detected-protocols [interfaces interface-id]

Parameters

interfaces interface-id—An interface ID or a list of interface IDs.

Default Configuration

N/A

Command Mode

Interface Configuration (Ethernet, port channel) mode

User Guidelines

This feature can only be used when the switch is in RSTP or MSTP mode.

Example

switchxxxxxx# clear spanning-tree detected-protocols

instance (MST)

To map VLANs to a Multiple Spanning Tree Protocol (MSTP) instance, use the instance MST Configuration mode command.

To revert to its default settings, use the no form of this command.

Syntax

instance instance-id vlan vlan-range

no instance instance-id vlan vlan-range

Parameters

instance-id—The MSTP instance ID. (Range: 0 to 15)

vlan vlan-range—Adds a range of VLANs to the MSTP instance. To specify a range, use a hyphen. To specify a series, use a comma. (Range: 1 to 4094)

Default Configuration

All VLANs are mapped to the Common and Internal Spanning Tree (CIST) instance (instance 0).

Command Mode

MST Configuration mode

User Guidelines

All VLANs that are not explicitly mapped to an MSTP instance are mapped to the CIST instance (instance 0) and cannot be unmapped from the CIST.

For two or more devices to be in the same MSTP region, they must have the same VLAN mapping, the same configuration revision number, and the same name.

Example

The following example maps a range of VLANs to the MSTP instance 1:

switchxxxxxx(config)# spanning-tree mst configuration
switchxxxxxx(config-mst)# instance 1 vlan 10-20

name (MST)

To define the name for an MSTP instance, use the name MST Configuration mode command.

To revert to its default setting, use the no form of this command.

Syntax

name string

no name

Parameters

string—The MSTP instance name. (Length: 1 to 32 characters)

Default Configuration

The default MSTP name is the bridge MAC address.

Command Mode

MST Configuration mode

Example

switchxxxxxx(config)# spanning-tree mst configuration
switchxxxxxx(config-mst)# name region1

revision (MST)

To define the revision number for current MSTP configuration, use the revision MST Configuration mode command.

To revert to its default setting, use the no form of this command.

Syntax

revision value

no revision

Parameters

value—Specifies an unsigned 16-bit number that identifies the revision of the current MSTP configuration. (Range: 0 to 65535)

Default Configuration

The default revision number is 0.

Command Mode

MST Configuration mode

Example

switchxxxxxx(config)# spanning-tree mst configuration
switchxxxxxx(config-mst)# revision 1

show spanning-tree

To show the STP configuration, use the show spanning-tree Privileged EXEC mode command.

Syntax

show spanning-tree

Parameters

N/A

Default Configuration

N/A

Command Mode

Privileged EXEC mode

Example

switchxxxxxx# show spanning-tree
Spanning tree enabled mode STP
Default port cost method: short
Loopback guard:  Disabled
Root ID Priority 32768
Address 64:d8:14:5d:6d:36
This switch is the root
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Number of topology changes 2 last change occurred 04:57:14 ago
Times: hold 0, topology change 0, notification 0
hello 2, max age 20, forward delay 15
Interfaces
Name State Prio.Nbr Cost Sts Role PortFast Type
--------- -------- -------- -------- ------ ---- -------- -----------------
fa22 enabled 128.22 19 Frw Desg No P2P (STP)

show spanning-tree interfaces

To show the STP statistics for specific interfaces, use the show spanning-tree interfaces Privileged EXEC mode command.

Syntax

show spanning-tree interfaces interface-id [statistic]

Parameters

interface-id—An interface ID or a list of interface IDs. The interface can be one of these types: Ethernet port or port channel.

statistic—(Optional) Displays the STP statistics for the specified interfaces.

Command Mode

Privileged EXEC mode

Examples

Example 1—The following example shows the STP information of gi1:

switchxxxxxx# show spanning-tree interfaces gi1
Port gi1 enabled
State: disabled                                Role: disabled
Port id: 128.1                                 Port cost: 200000
Type: Shared Boundary                          Port Fast: No
Designated bridge Priority : 0                 Address: 00:00:00:00:00:00
Designated port id:   0.0                      Designated path cost: 0
BPDU Filter: Disabled                          BPDU guard: Disabled
BPDU: sent 0, received 0

Example 2—The following example shows the STP statistics of gi1:

switchxxxxxx# show spanning-tree interfaces gi1 statistic
 STP Port Statistic
==================================================
Port                            : fa1
Configuration BDPUs Received    : 0
TCN BDPUs Received              : 8
MSTP BDPUs Received             : 15
Configuration BDPUs Transmitted : 86696
TCN BDPUs Transmitted           : 0
MSTP BDPUs Transmitted          : 0

show spanning-tree mst

To show the MSTP instance information, use the show spanning-tree mst Privileged EXEC mode command.

Syntax

show spanning-tree mst instance-id

Parameters

instance-id—The MSTP instance ID. (Range: 0 to 15)

Command Mode

Privileged EXEC mode

Example

switchxxxxxx# show spanning-tree mst 1
 MST Instance Information
============================================================
            Instance Type : MSTI (1)
          Instance Status : Disabled
        Bridge Identifier : 32768/ 0/00:03:6D:00:10:00
------------------------------------------------------------
     Regional Root Bridge : 32768/ 0/00:03:6D:00:10:00
  Internal Root Path Cost : 0
           Remaining Hops : 20
         Topology changes : 4
     Last Topology Change : 0
------------------------------------------------------------
 VLANs mapped: 1-4094
============================================================
Interface        Role Sts Cost      Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
gi1              Desg FWD 200000    128.1    P2P (STP)

show spanning-tree mst configuration

To show the MSTP instance configuration, use the show spanning-tree mst configuration Privileged EXEC mode command.

Syntax

show spanning-tree mst configuration

Parameters

N/A

Command Mode

Privileged EXEC mode

Example

switchxxxxxx# show spanning-tree mst configuration
Name      [00:03:6D:00:10:A0]
Revision  0     Instances configured 2
Instance  Vlans mapped
--------  -----------------------------------------------------------------
0           1,5-4094
1           2-4
---------------------------------------------------------------------------

show spanning-tree mst interfaces

To show the MSTP instance information for specific interfaces, use the show spanning-tree mst interfaces Privileged EXEC mode command.

Syntax

show spanning-tree mst instance-id interfaces interface-id

Parameters

instance-id—The MSTP instance ID. (Range: 0 to 15)

interface-id—An interface ID or a list of interface IDs. The interface can be one of these types: Ethernet port or port channel.

Command Mode

Privileged EXEC mode

Example

switchxxxxxx# show spanning-tree mst 1 interfaces gi1
 MST Port Information
============================================================
 Instance Type : MSTI (1)
------------------------------------------------------------
      Port Identifier : 128/1
   Internal Path-Cost : 0        /200000
------------------------------------------------------------
    Regional Root Bridge : 0/00:00:00:00:00:00
      Internal Root Cost : 0
       Designated Bridge : 0/00:00:00:00:00:00
 Internal Port Path Cost : 200000
               Port Role : Disabled
              Port State : Disabled
------------------------------------------------------------

spanning-tree

To enable STP on the switch, use the spanning-tree Global Configuration mode command.

To disable STP on the switch, use the no form of this command.

Syntax

spanning-tree

no spanning-tree

Parameters

N/A

Default Configuration

STP is enabled.

Command Mode

Global Configuration mode

Example

switchxxxxxx(config)# spanning-tree

spanning-tree bpdu (Global)

To define Bridge Protocol Data Unit (BPDU) handling when STP is disabled globally, use the spanning-tree bpdu Global Configuration mode command.

To revert to its default setting, use the no form of this command.

Syntax

spanning-tree bpdu {filtering | flooding}

no spanning-tree bpdu

Parameters

filtering—Filters BPDU packets when STP is disabled globally.

flooding—Floods BPDU packets unconditionally.

Default Configuration

The default setting is flooding.

Command Mode

Global Configuration mode

User Guidelines

The filtering and flooding modes are relevant when STP is disabled globally or on a single interface.

Example

switchxxxxxx(config)# spanning-tree bpdu flooding

spanning-tree bpdu-filter (Interface)

To define BPDU filtering when STP is enabled globally or on a single interface, use the spanning-tree bpdu-filter Interface Configuration mode command.

To revert to its default setting, use the no form of this command.

Syntax

spanning-tree bpdu-filter {disable | enable}

no spanning-tree bpdu-filter

Parameters

disable—Specifies that the interface sends and receives BPDU packets normally.

enable—Specifies that the interface does not send BPDU packets and filters the received BPDU packets.

Default Configuration

BPDU filter is disabled.

Command Mode

Interface Configuration (Ethernet, port channel) mode

Example

switchxxxxxx(config)# interface gi3
switchxxxxxx(config-if)# spanning-tree bpdu-filter enable

spanning-tree bpdu-guard (Interface)

To shut down an interface when it receives a BPDU, use the spanning-tree bpdu-guard Interface Configuration mode command.

To revert to its default setting, use the no form of this command.

Syntax

spanning-tree bpdu-guard {disable | enable}

no spanning-tree bpdu-guard

Parameters

disable—Disables BPDU guard.

enable—Enables BPDU guard.

Default Configuration

BPDU guard is disabled.

Command Mode

Interface Configuration (Ethernet, port channel) mode

User Guidelines

The command can be enabled when STP is enabled globally and on the interface.

Example

The following example shuts down fa5 when it receives an BPDU:

switchxxxxxx(config)# interface gi5
switchxxxxxx(config-if)# spanning-tree bpdu-guard enable

spanning-tree cost (Interface)

To configure the STP path cost for an interface, use the spanning-tree cost Interface Configuration mode command.

To revert to its default setting, use the no form of this command.

Syntax

spanning-tree cost cost

no spanning-tree cost

Parameters

cost—The port path cost. (Range: 0 to 200000000, 0 indicates Auto)

Default Configuration

The default path cost is determined by the port speed and the path cost method (long or short):

Interface

Long

Short

port channel

20,000

4

Gigabit Ethernet (1000 Mbps)

20,000

4

Fast Ethernet (100 Mbps)

200,000

19

Ethernet (10 Mbps)

2,000,000

100

Command Mode

Interface Configuration (Ethernet, port channel) mode

Example

The following example configures the STP path cost on fa15 to 35000:

switchxxxxxx(config)# interface gi15
switchxxxxxx(config-if)# spanning-tree cost 35000

spanning-tree forward-time

To configure the STP bridge forward delay time, which is the amount of time that a port remains in the listening and learning states before entering the forwarding state, use the spanning-tree forward-time Global Configuration mode command.

To revert to its default setting, use the no form of this command.

Syntax

spanning-tree forward-time seconds

no spanning-tree forward-time

Parameters

seconds—The STP forward delay time. (Range: 4 to 30 seconds)

Default Configuration

15 seconds

Command Mode

Global Configuration mode

User Guidelines

When configuring the forwarding time, the following relationship should be maintained:

2*(Forward-Time - 1) >= Max-Age

Example

switchxxxxxx(config)# spanning-tree forward-time 25

spanning-tree hello-time

To configure how often the switch broadcasts the hello messages to other devices, use the spanning-tree hello-time Global Configuration mode command.

To revert to its default setting, use the no form of this command.

Syntax

spanning-tree hello-time seconds

no spanning-tree hello-time

Parameters

seconds—The STP hello time in seconds. (Range: 1 to 10)

Default Configuration

2 seconds

Command Mode

Global Configuration mode

User Guidelines

When configuring the hello time, the following relationship should be maintained:

Max-Age >= 2*(Hello-Time + 1)

Example

switchxxxxxx(config)# spanning-tree hello-time 5

spanning-tree link-type (Interface)

To specify the RSTP link type for an interface, use the spanning-tree link-type Interface Configuration mode command.

To revert to its default setting, use the no form of this command.

Syntax

spanning-tree link-type {point-to-point | shared}

no spanning-tree link-type

Parameters

point-to-point—Specifies that the port link type is point-to-point.

shared—Specifies that the port link type is shared.

Default Configuration

The default is shared.

Command Mode

Interface Configuration (Ethernet, port channel) mode

Example

switchxxxxxx(config)# interface gi15
switchxxxxxx(config-if)# spanning-tree link-type point-to-point

spanning-tree loopback-guard

Use the spanning-tree loopback-guard Global Configuration command to shutdown an interface if it receives a loopback BPDU.

Use the no form of this command to return the default setting.

Syntax

spanning-tree loopback-guard

no spanning-tree loopback-guard

Parameters

N/A

Default Configuration

Spanning-tree loopback guard is disabled.

Command Mode

Global Configuration mode

User Guidelines

This command enables shutting down all interfaces on which a loopback BPDU is received.

Example

The following example enables shutting down all interfaces on which a loopback BPDU is received:

switchxxxxxx(config)# spanning-tree loopback-guard

spanning-tree mst port-priority

To configure the priority of a port, use the spanning-tree mst port-priority Interface Configuration mode command.

To revert to its default setting, use the no form of this command.

Syntax

spanning-tree mst instance-id port-priority priority

no spanning-tree mst instance-id port-priority

Parameters

instance-id—The spanning tree instance ID. (Range: 0 to 15)

priority—The port priority. (Range: 0 to 240)

Default Configuration

The default port priority is 128.

Command Mode

Interface Configuration (Ethernet, port channel) mode

User Guidelines

The priority value must be a multiple of 16.

Example

The following example configures the port priority of gi1 to 144:

switchxxxxxx(config)# interface gi1
switchxxxxxx(config-if)# spanning-tree mst 1 port-priority 144

spanning-tree max-hops

To configure the number of hops in an MSTP region before BDPU is discarded and the port information is aged out, use the spanning-tree max-hops Global Configuration mode command.

To revert to its default setting, use the no form of this command.

Syntax

spanning-tree max-hops hop-count

no spanning-tree max-hops

Parameters

hop-count—The number of hops in an MSTP region before BDPU is discarded. (Range: 1 to 40)

Default Configuration

The default number of hops is 20.

Command Mode

Global Configuration mode

Example

switchxxxxxx(config)# spanning-tree mst max-hops 10

spanning-tree max-age

To set the interval in seconds that the switch can wait without receiving a configuration message before attempting to redefine its own configuration, use the spanning-tree max-age Global Configuration mode command.

To revert to its default setting, use the no form of this command.

Syntax

spanning-tree max-age seconds

no spanning-tree max-age

Parameters

seconds—The interval in seconds that the switch can wait without receiving a configuration message, before attempting to redefine its own configuration. (Range: 6 to 40)

Default Configuration

The default value is 20 seconds.

Command Mode

Global Configuration mode

User Guidelines

When configuring the maximum age, the following relationships should be maintained:

2*(Forward-Time - 1) >= Max-Age

Max-Age >= 2*(Hello-Time + 1)

Example

switchxxxxxx(config)# spanning-tree max-age 10

spanning-tree mode

To set the STP mode, use the spanning-tree mode Global Configuration mode command.

Syntax

spanning-tree mode {mstp | rstp | stp}

Parameters

mstp—Enables the Multiple STP (MSTP) mode.

rstp—Enables the Rapid STP (RSTP) mode.

stp—Enables the classic STP mode.

Default Configuration

The default mode is classic STP.

Command Mode

Global Configuration mode

User Guidelines

In the RSTP mode, the switch uses STP when the neighbor device uses STP.

In the MSTP mode, the switch uses RSTP when the neighbor device uses RSTP, and uses STP when the neighbor device uses STP.

Example

switchxxxxxx(config)# spanning-tree mode mstp

spanning-tree mst configuration

To enter the MST Configuration mode and enable configuring an MSTP region, use the spanning-tree mst configuration Global Configuration mode command.

Syntax

spanning-tree mst configuration

Command Mode

Global Configuration mode

User Guidelines

For two or more switches to be in the same MSTP region, they must contain the same VLAN mapping, the same configuration revision number, and the same name.

Example

switchxxxxxx(config)# spanning-tree mst configuration
switchxxxxxx(config-mst)# instance 1 vlan 10-20
switchxxxxxx(config-mst)# name region1
switchxxxxxx(config-mst)# revision 1

spanning-tree mst cost

To configure the path cost for MSTP calculations, use the spanning-tree mst cost Interface Configuration mode command. If a loop occurs, the STP considers the path cost when selecting an interface to put in the Forwarding state.

To revert to its default setting, use the no form of this command.

Syntax

spanning-tree mst instance-id cost cost

no spanning-tree mst instance-id cost

Parameters

instance-id—The MSTP instance ID. (Range: 0 to 15)

cost—The port path cost. (Range: 1 to 200000000, 0 means Auto)

Default Configuration

The default path cost is determined by the port speed and the path cost method (long or short):

Interface

Long

Short

port channel

20,000

4

Gigabit Ethernet (1000 Mbps)

20,000

4

Fast Ethernet (100 Mbps)

200,000

19

Ethernet (10 Mbps)

2,000,000

100

Command Mode

Interface Configuration (Ethernet, port channel) mode

Example

switchxxxxxx(config)# interface gi9
switchxxxxxx(config-if)# spanning-tree mst 1 cost 4

spanning-tree mst priority

To configure the device priority for the specified STP instance, use the spanning-tree mst priority Global Configuration mode command.

To revert to its default setting, use the no form of this command.

Syntax

spanning-tree mst instance-id priority priority

no spanning-tree mst instance-id priority

Parameters

instance-id—The STP instance ID. (Range: 0 to 15)

priority—The priority for the specified STP instance. This setting ensures the probability that the switch is selected as the root switch. A lower value increases the probability that the switch is selected as the root switch. (Range: 0 to 61440)

Default Configuration

The default priority is 32768.

Command Mode

Global Configuration mode

User Guidelines

The priority value must be a multiple of 4096.

The switch with the lowest priority is the root of the STP.

Example

switchxxxxxx(config)# spanning-tree mst 1 priority 4096

spanning-tree pathcost method

To set the default path cost method, use the spanning-tree pathcost method Global Configuration mode command.

Syntax

spanning-tree pathcost method {long | short}

Parameters

long—The default port path costs are within the range 1 through 200,000,000.

short—The default port path costs are within the range 1 through 65,535.

Default Configuration

Long path cost method

Command Mode

Global Configuration mode

User Guidelines

This command applies to all STP instances on the switch.

  • If the short method is selected, the switch calculates cost in the range 1 through 65,535.

  • If the long method is selected, the switch calculates cost in the range 1 through 200,000,000.

Example

The following example sets the default path cost method to Long:

switchxxxxxx(config)# spanning-tree pathcost method long

spanning-tree portfast

To enable the PortFast mode on an interface, use the spanning-tree portfast Interface Configuration mode command.

To disable the PortFast mode on an interface, use the no form of this command.

Syntax

spanning-tree portfast

no spanning-tree portfast

Parameters

N/A

Default Configuration

The PortFast mode is disabled.

Command Mode

Interface Configuration (Ethernet, port channel) mode

User Guidelines

In the PortFast mode, the interface is immediately put into the forwarding state upon linkup, without waiting for the standard forward delay time.

Example

The following example enables the PortFast mode on gi15:

switchxxxxxx(config)# interface gi15
switchxxxxxx(config-if)# spanning-tree portfast

spanning-tree port-priority

To configure the STP priority for an interface, use the spanning-tree port-priority Interface Configuration mode command.

To revert to its default setting, use the no form of this command.

Syntax

spanning-tree port-priority priority

no spanning-tree port-priority

Parameters

priority—The port priority. (Range: 0 to 240)

Default Configuration

The default port priority is 128.

Command Mode

Interface Configuration (Ethernet, port channel) mode

User Guidelines

The priority value must be a multiple of 16.

Example

switchxxxxxx(config)# interface gi15
switchxxxxxx(config-if)# spanning-tree port-priority 96

spanning-tree priority

To configure the device STP priority used to determine which bridge is selected as the root bridge, use the spanning-tree priority Global Configuration mode command.

To revert to its default setting, use the no form of this command.

Syntax

spanning-tree priority priority

no spanning-tree priority

Parameters

priority—The bridge priority. (Range: 0 to 61440)

Default Configuration

The default priority is 32768.

Command Mode

Global Configuration mode

User Guidelines

The priority value must be a multiple of 4096. The switch with the lowest priority is the root of the STP. When more than one switch has the lowest priority, the switch with the lowest MAC address is selected as the root.

Example

switchxxxxxx(config)# spanning-tree priority 12288

spanning-tree tx-hold-count

To set the Tx-Hold-Count used to limit the maximum transmission packet number per second, use the spanning-tree tx-hold-count Global Configuration mode command.

To revert to its default setting, use the no form of this command.

Syntax

spanning-tree tx-hold-count value

no spanning-tree tx-hold-count

Parameters

value—The Tx-Hold-Count number. (Range: 1 to 10)

Default Configuration

The default value is 6.

Command Mode

Global Configuration mode

Example

switchxxxxxx(config) # spanning-tree tx-hold-count 5