Course contents

Chapter 6: Spanning Tree ProtocolLesson 14 of 25

Packet Tracer lab: STP, Rapid PVST+ and PortFast

A three-switch triangle: read the default tree, choose the root, switch to Rapid PVST+, protect edge ports and test failover.

Intermediate · 25 min read

Technical definition

Packet Tracer STP lab is a hands-on exercise on a three-switch triangle. You read the default spanning tree, choose the root bridge yourself, convert to Rapid PVST+, protect edge ports with PortFast and BPDU guard, and test what happens when a link fails.

What you will build

This walkthrough was written from Cisco IOS documentation and Packet Tracer behaviour as generally described. It has not been run in Packet Tracer here, so port names and prompts can differ slightly on your version.

Packet Tracer topology: a three-switch triangle with two PCs
Packet Tracer topology: a three-switch triangle with two PCsSW1, SW2 and SW3 are joined in a triangle by trunks. PC1 is on SW2 Fa0/1 and PC2 on SW3 Fa0/1, both in VLAN 1. SW1 will become the root bridge.Gi0/1Gi0/2Gi0/2Fa0/1Fa0/1SW1future rootSW2SW3PC1.11PC2.12
Triangle links: SW1 Gi0/1 to SW2 Gi0/1, SW1 Gi0/2 to SW3 Gi0/1, SW2 Gi0/2 to SW3 Gi0/2. PC1 192.168.1.11 and PC2 192.168.1.12, mask 255.255.255.0.

Step 1: build it and read the default tree

  1. Place three 2960 switches and two PCs; cable with copper straight-through as shown and wait for the lights.
  2. On each switch run show spanning-tree. Find the line This bridge is the root: only one switch says it.
  3. Draw the result: which switch is root, which ports are Root and Desg (designated), and which one port is Altn/BLK.
Example output · based on Cisco documentation; exact format varies by platform and software version
SW3#show spanning-tree
VLAN0001
  Spanning tree enabled protocol ieee
  Root ID    Priority    32769
             Address     00D0.BC12.3401
             Cost        19
             Port        1(GigabitEthernet0/1)
  Bridge ID  Priority    32769  (priority 32768 sys-id-ext 1)

Interface        Role Sts Cost      Prio.Nbr Type
Gi0/1            Root FWD 19        128.1    P2p
Gi0/2            Altn BLK 19        128.2    P2p
Example output; your MAC addresses and costs will differ. Here SW3 is not the root: its Gi0/1 is the root port toward the root, and Gi0/2 is blocked (alternate), which is what breaks the loop.

Step 2: choose the root bridge

! SW1 spanning-tree vlan 1 root primary ! SW2 (backup root) spanning-tree vlan 1 root secondary

root primary lowers SW1's priority below the current root's (typically to 24576); root secondary sets a value that makes SW2 the next choice. You can also set an explicit value with spanning-tree vlan 1 priority 4096.

Run show spanning-tree on SW1 again: it now says it is the root, and the blocked port has moved.

Step 3: switch to Rapid PVST+

! on all three switches spanning-tree mode rapid-pvst

Rapid PVST+ converges in about a second instead of 30 to 50. Use the same mode on every switch; mixed modes interoperate but lose the speed benefit on the shared links.

Confirm with show spanning-tree summary, which names the mode.

Step 4: protect the edge ports

! SW2 and SW3 (on the PC ports) interface FastEthernet0/1 switchport mode access spanning-tree portfast spanning-tree bpduguard enable

PortFast puts the port straight into forwarding, and BPDU guard shuts it down (err-disabled) if a switch is plugged in.

To test the guard, add a fourth switch and connect it to a PC port. It should go err-disabled. Recover with shutdown then no shutdown on the port.

Step 5: test a failure

  1. On PC1 open the Command Prompt and run ping -t 192.168.1.12 (a continuous ping).
  2. On SW1 shut down Gi0/1 to break one root path.
  3. Watch the ping: with Rapid PVST+ there are only a few lost replies before it recovers; with classic PVST+ the gap is far longer.
  4. Bring the interface back with no shutdown and check that the tree returns to normal.

What to record

Results to write down
Results to write downCheck; Before changes; After changes. Root bridge: Lowest MAC address SW1, set by priority Mode: PVST+ Rapid PVST+ Blocked port: On the triangle's far side May move after the root change Failover: Slow (tens of seconds) About a second PC ports: Wait to reach forwarding PortFast: forwarding at onceCheckBefore changesAfter changesRoot bridgeLowest MAC addressSW1, set by priorityModePVST+Rapid PVST+Blocked portOn the triangle's far sideMay move after the root changeFailoverSlow (tens of seconds)About a secondPC portsWait to reach forwardingPortFast: forwarding at once

On small screens, swipe sideways or focus the diagram and use the arrow keys.

Fill the columns in as you go; the pattern matters more than the exact values.

Common Packet Tracer problems

  • The ping drops for a long time: check that every switch runs rapid-pvst.
  • PortFast refused on a trunk: it belongs on access ports only (or use trunk PortFast deliberately).
  • BPDU guard did not trigger in the simulation: the connected device must actually send BPDUs, so use a switch, not a PC.

Test yourself

Predict · scenario 1

In a three-switch triangle with spanning tree, how many ports are blocked?

Predict · scenario 2

Which command makes SW1 the root bridge for VLAN 1?

Predict · scenario 3

What does BPDU guard do when a BPDU arrives on a PortFast port?

Predict · scenario 4

Why switch to Rapid PVST+ in this lab?

Predict · scenario 5

In show spanning-tree, which port state/role breaks the loop?

FAQ

Why does the lab have a loop?
The triangle has three links between three switches. Without spanning tree it would loop frames forever; with it, one port is blocked and acts as a backup.
Is there any risk of a real loop in Packet Tracer?
Only if you disable spanning tree. Leave it on, and use the simulation controls if the topology becomes busy.
Why set the root manually?
The default root is the switch with the lowest MAC address, which is often an old or poorly placed switch. Setting a priority puts the root where you want it.