Configuring PVST+ and RPVST+
Configuring PVST+ and RPVST+
This chapter describes how to configure the Spanning Tree Protocol (STP) on port-based VLANs on the Cisco
router. The router can use the per-VLAN spanning-tree plus (PVST+) protocol based on the IEEE 802.1D
standard and Cisco proprietary extensions, or the rapid per-VLAN spanning-tree plus (rapid-PVST+) protocol
based on the IEEE 802.1w standard.
For information about the Multiple Spanning Tree Protocol (MSTP) and how to map multiple VLANs to the
same spanning-tree instance, see the Multiple Spanning Tree Protocol chapter.
Note For complete syntax and usage information for the commands used in this chapter, see the command reference
for this release.
STP Overview
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 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 port priority 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.
Switch Priority Value Extended System ID (Set Equal to the VLAN ID)
Bit Bit Bit Bit Bit Bit Bit Bit 9 Bit 8 Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1
16 15 14 13 12 11 10
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.
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. For more information, see the Configuring the Root
Switch section, the Configuring a Secondary Root Switch section, and the Configuring the Switch Priority of
a VLAN section.
Spanning tree is not enabled by default. Once the spanning tree mode is selected, each VLAN on ports goes
through the blocking state and the transitionary 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 spanning-tree interface in the forwarding state, this process
occurs:
1. The interface is in the listening state while spanning tree waits for protocol information to transition the
interface to the blocking state.
2. While spanning tree waits 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, or to each switch STP port. 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 participating in spanning tree 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.
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 non operational.
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
becomes the root switch, you force a spanning-tree recalculation to form a new topology with the ideal switch
as the root.
Figure 2: Spanning-Tree Topology
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.
You can also create redundant links between switches by using EtherChannel groups.
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.
SUMMARY STEPS
1. configure terminal
2. spanning-tree mode {pvst | rapid-pvst
3. spanning-tree vlan vlan-range
4. end
DETAILED STEPS
Step 2 spanning-tree mode {pvst | rapid-pvst Configure a spanning-tree mode on STP ports on the switch.
• Select pvst to enable PVST+.
• Select rapid-pvst to enable rapid PVST+.
Step 3 spanning-tree vlan vlan-range Configures STP on the range of VLAN specified.
SUMMARY STEPS
1. configure terminal
2. interface TenGigabitEthernetslot/subslot/port
3. no ip address
4. service instance trunk trunk id ethernet
5. encapsulation dot1q vlan-id
6. rewrite ingress tag pop 1 symmetric
7. l2protocol peer stp
8. bridge-domain from encapsulation
9. end
DETAILED STEPS
Note You must configure l2protocol peer stp command under all the EFP where you prefer to run STP.
Caution When spanning tree is disabled and loops are present in the topology, excessive traffic and indefinite packet
duplication can drastically reduce network performance.
Beginning in privileged EXEC mode, follow these steps to disable spanning-tree on a per-VLAN basis. This
procedure is optional.
SUMMARY STEPS
1. configure terminal
2. no spanning-tree vlan vlan-id
3. end
4. show spanning-tree vlan vlan-id
DETAILED STEPS
To re-enable spanning-tree, use the spanning-tree vlan vlan-id global configuration command.
VLAN0010
Spanning tree enabled protocol ieee
Root ID Priority 32778
Address a89d.21ed.bbbd
Cost 6
Port 18 (GigabitEthernet0/0/11)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
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 Table 14-1 on page 14-4 .)
Note The spanning-tree vlan vlan-id root global configuration command fails if the value necessary to be the root
switch is less than 1.
If your network consists of switches that both do 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.
Note 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.
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.
Note 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 vlanvlan-id hello-time,
spanning-tree vlanvlan-id forward-time, and the spanning-tree vlanvlan-id max-age global configuration
commands.
Beginning in privileged EXEC mode, follow these steps to configure a switch to become the root for the
specified VLAN. This procedure is optional.
SUMMARY STEPS
1. configure terminal
2. spanning-tree vlan vlan-id root primary [diameter net-diameter [hello-time seconds ]]
3. end
4. show spanning-tree detail
5. copy running-config startup-config
DETAILED STEPS
Step 2 spanning-tree vlan vlan-id root primary [diameter Configure a switch to become the root for the specified
net-diameter [hello-time seconds ]] VLAN.
Step 5 copy running-config startup-config (Optional) Save your entries in the configuration file.
To return to the default setting, use the no spanning-tree vlan vlan-id root global configuration command.
SUMMARY STEPS
1. configure terminal
2. spanning-tree vlan vlan-id root secondary [diameter net-diameter [hello-time seconds ]]
3. end
4. show spanning-tree detail
5. copy running-config startup-config
DETAILED STEPS
Step 5 copy running-config startup-config (Optional) Save your entries in the configuration file.
To return to the default setting, use the no spanning-tree vlan vlan-id root global configuration command.
SUMMARY STEPS
1. configure terminal
2. interface interface-id
3. spanning-tree port-priority priority
4. end
5. Do one of the following:
• show spanning-tree interface interface-id
• show spanning-tree vlan vlan-id
6. copy running-config startup-config
DETAILED STEPS
Step 3 spanning-tree port-priority priority Configure the port priority for the spanning-tree port.
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 6 copy running-config startup-config (Optional) Save your entries in the configuration file.
Note The show spanning-tree interface interface-id privileged EXEC c ommand displays information only if the
port is in a link-up operative state. Otherwise, you can use the show running-config interface privileged
EXEC command to confirm the configuration.
To return to the default spanning-tree setting, use the no spanning-tree [vlan vlan-id port-priority interface
configuration command.
SUMMARY STEPS
1. configure terminal
2. interface interface-id
3. spanning-tree cost cost
4. end
5. Do one of the following:
• show spanning-tree interface interface-id
• show spanning-tree vlan vlan-id
6. copy running-config startup-config
DETAILED STEPS
Step 6 copy running-config startup-config (Optional) Save your entries in the configuration file.
Note The show spanning-tree interface interface-id privileged EXEC c ommand displays information only for
ports that are in a link-up operative state. Otherwise, you can use the show running-config privileged EXEC
co mmand to confirm the configuration.
To return to the default setting, use the no spanning-tree [vlan vlan-id ] cost interface configuration command.
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.
Beginning in privileged EXEC mode, follow these steps to configure the switch priority of a VLAN. This
procedure is optional.
SUMMARY STEPS
1. configure terminal
2. spanning-tree vlan vlan-id priority priority
3. end
4. show spanning-tree vlan vlan-id
5. copy running-config startup-config
DETAILED STEPS
Step 2 spanning-tree vlan vlan-id priority priority Configure 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 5 copy running-config startup-config (Optional) Save your entries in the configuration file.
To return to the default setting, use the no spanning-tree vlan vlan-id priority global configuration command.
Variable Description
Hello timer Controls how often the switch broadcasts hello messages to other switches.
Forward-delay timer Controls how long each of the listening and learning states last before the STP
port begins forwarding.
Maximum-age timer Controls the amount of time the switch stores protocol information received
on an STP port.
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 hello time.
Beginning in privileged EXEC mode, follow these steps to configure the hello time of a VLAN. This procedure
is optional.
SUMMARY STEPS
1. configure terminal
2. spanning-tree vlan vlan-id hello-time seconds
3. end
4. show spanning-tree vlan vlan-id
5. copy running-config startup-config
DETAILED STEPS
Step 2 spanning-tree vlan vlan-id hello-time seconds Configure the hello time of a VLAN. The hello time is the
interval between the generation of configuration messages
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
Step 5 copy running-config startup-config (Optional) Save your entries in the configuration file.
To return to the default setting, use the no spanning-tree vlan vlan-id hello-time global configuration
command.
SUMMARY STEPS
1. configure terminal
2. spanning-tree vlan vlan-id forward-time seconds
3. end
4. show spanning-tree vlan vlan-id
5. copy running-config startup-config
DETAILED STEPS
Step 2 spanning-tree vlan vlan-id forward-time seconds Configure the forward time of a VLAN. The forward delay
is the number of seconds a spanning-tree port 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 5 copy running-config startup-config (Optional) Save your entries in the configuration file.
To return to the default setting, use the no spanning-tree vlan vlan-id forward-time global configuration
command.
SUMMARY STEPS
1. configure terminal
2. spanning-tree vlan vlan-id max-age seconds
3. end
4. show spanning-tree vlan vlan-id
5. copy running-config startup-config
DETAILED STEPS
Step 2 spanning-tree vlan vlan-id max-age seconds Configure 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 5 copy running-config startup-config (Optional) Save your entries in the configuration file.
To return to the default setting, use the no spanning-tree vlan vlan-id max-age global configuration command.
Command Purpose
show spanning-tree active Displays spanning-tree information only on active spanning-tree interfaces.
Command Purpose
show spanning-tree interface interface-id Displays spanning-tree information for the specified spanning-tree interface.
show spanning-tree summary totals Displays a summary of interface states or displays the total lines of the STP state section.
You can clear spanning-tree counters by using the clear spanning-tree [interfaceinterface-id ] privileged
EXEC command.
For information about other keywords for the show spanning-tree privileged EXEC command, see the
command reference for this release.