Routelearn.net
Course menu

Course 6: Spanning Tree ProtocolLesson 3.2 (12 of 24 in this course)33 of 91 in the CCNA series

Configuring PVST+

Choosing the root, tuning cost and port priority, and verifying the result.

Intermediate · 8 min read

PVST+ (Per-VLAN Spanning Tree Plus) is Cisco’s Spanning Tree implementation that runs a separate STP instance for each VLAN. Configuring it means choosing the root bridge per VLAN with bridge priority and adjusting port cost and port priority to control which links forward for each VLAN.

In simple terms: Each VLAN gets its own loop-free layout, and you decide which switch is the centre of each one and which cables it should use.

⚠️ Commands are based on Cisco IOS / IOS XE documentation and haven't been run in a lab here. Interface names vary by platform.

1. Choose the mode

spanning-tree mode pvst

Classic 802.1D, one tree per VLAN. For Rapid PVST+ (the Rapid Spanning Tree lessons), use 'spanning-tree mode rapid-pvst'. Use the same mode on every switch.

2. Choose the root bridge yourself

Why: if you do nothing, the switch with the lowest MAC becomes the root. That might be an old access switch in a cupboard. The root should be a strong, central switch, such as a core or distribution switch.

spanning-tree vlan 10 root primary spanning-tree vlan 20 root secondary

On SW1. 'root primary' is a shortcut. It sets priority 24576, or 4096 lower than the current root if that's needed to win. 'root secondary' sets 28672, so this switch takes over if the main root fails.

spanning-tree vlan 10 priority 24576

The other way: set the number yourself. It must be a multiple of 4096 (0, 4096, 8192 … 61440).

The shortcut only checks the current root once, when you type it. Setting the number yourself gives a more predictable result, so many engineers prefer it.

What happens if you don't choose

Situation: three switches, all with the default priority 32768, and VLANs 1, 10, 20 and 30. Each switch adds the VLAN number to its priority. So the same switch shows a different number in each VLAN. But all switches add the same VLAN number, so the MAC address always decides:

Example output · based on Cisco documentation; exact format varies by platform and software version
SW3#show spanning-tree root
                                        Root    Hello Max Fwd
Vlan                   Root ID          Cost    Time  Age Dly  Root Port
---------------- -------------------- --------- ----- --- ---  ------------
VLAN0001         32769 0200.0000.0001         4    2   20  15  Gi1/0/1
VLAN0010         32778 0200.0000.0001         4    2   20  15  Gi1/0/1
VLAN0020         32788 0200.0000.0001         4    2   20  15  Gi1/0/1
VLAN0030         32798 0200.0000.0001         4    2   20  15  Gi1/0/1
SW1 has the lowest MAC, so it wins every VLAN. There is one root for all VLANs, just like CST, so you get none of PVST+'s benefits. The priorities 32769/32778/32788/32798 are 32768 + the VLAN number.

Spread the roots

! SW1 spanning-tree vlan 1,10 priority 0 ! SW2 spanning-tree vlan 20 priority 0 ! SW3 spanning-tree vlan 30 priority 0

Now each VLAN has its own root. Also set a backup root for each VLAN on another switch ('root secondary' or priority 4096), so you choose the backup too.

Shortcut or your own number? root primary looks at the current root only once. If the root's priority is above 24576, it sets 24576. If not, it sets a value 4096 lower than the root. It doesn't keep checking, so a switch added later with a lower priority can still win. Setting priority 0 (or 4096) yourself is more predictable. Most designs do this.

3. Change the path with port cost

Port cost changes which port a switch chooses as its root port. It only affects the switch where you set it.

interface GigabitEthernet1/0/1 spanning-tree vlan 10 cost 30

On SW3's port toward SW1. In VLAN 10 this path now costs 30, so the path through SW2 (4 + 4 = 8) wins.

DPRPDPBLKcost 30 on SW3DPRPSW1priority 24576SW2priority 32768SW3priority 32768PC APC B
  1. 1. New root port. SW3's best VLAN 10 path now goes through SW2 (8 is less than 30).
  2. 2. The old path is blocked. On the SW1–SW3 link, SW1 (cost 0) is designated. So SW3's end is now blocked for VLAN 10.

4. Port priority: set it on the switch above

interface GigabitEthernet1/0/2 spanning-tree vlan 10 port-priority 64

The default is 128. Lower is better. On most Catalyst switches you set it in steps of 16.

Watch out: port priority is sent in the BPDUs as the sender port ID. So it changes the choice of the neighbour switch, not your own switch. Use it on the switch closer to the root, when two cables go to the same switch below it and the costs are equal.

5. Verify

Example output · based on Cisco documentation; exact format varies by platform and software version
SW1#show spanning-tree root
                                        Root    Hello Max Fwd
Vlan                   Root ID          Cost    Time  Age Dly  Root Port
---------------- -------------------- --------- ----- --- ---  ------------
VLAN0010         24586 0200.0000.0001         0    2   20  15
VLAN0020         24596 0200.0000.0002         4    2   20  15  Gi1/0/1
On SW1: it is the root for VLAN 10 (cost 0, no root port). It reaches VLAN 20's root (SW2, priority 24576 + 20) at cost 4, through Gi1/0/1.
show spanning-tree vlan 10

Shows the root ID, this switch's bridge ID, and the role (Root/Desg/Altn), state and cost of every port.

show spanning-tree summary

Shows the mode, the VLANs this switch is root for, and global settings such as PortFast.

Check yourself

Predict · scenario 1

You want SW3 to stop using its direct link to SW1 for VLAN 10. Where do you change the cost?

Predict · scenario 2

Which priority value is NOT valid?