Spanning Tree Protocol

CCNA · LAB 5

Spanning Tree Protocol and Configuring PortFast

Objectives

  • Identify the Root Bridge, Link Cost, Root Port, Designated Port, and Alternate (Blocked) Port in an STP topology.
  • Understand how Spanning Tree Protocol prevents Layer 2 switching loops.
  • Configure PortFast on switch ports connected to end devices such as servers.
  • Verify STP operation and PortFast configuration using Cisco IOS commands.

Theory

Spanning Tree Protocol (STP) is a Layer 2 protocol used in switched networks to prevent switching loops. It identifies redundant paths and blocks selected ports to ensure that there is only one active forwarding path between network segments.

1. Root Bridge

  • The Root Bridge is the central reference switch in the STP topology.
  • It is elected based on the lowest Bridge ID (Bridge Priority + MAC Address).
  • The default bridge priority is 32768.
  • All path calculations in the network start from the Root Bridge.
  • Every active STP topology has only one Root Bridge per VLAN or spanning-tree instance.

2. Link Cost

  • Link Cost is a value assigned to each interface to determine the best path to the Root Bridge.
  • Lower cost means a more preferred path.
  • It is based on interface bandwidth: higher bandwidth generally has lower STP cost.
  • Switches use the accumulated path cost to calculate the best route toward the Root Bridge.
Interface Name Interface Speed STP Cost
Ethernet 10 Mbps 100
FastEthernet 100 Mbps 19
GigabitEthernet 1 Gbps 4
TenGigabitEthernet 10 Gbps 2

3. Root Port

  • The Root Port is the port on a non-root switch that has the lowest-cost path to the Root Bridge.
  • Each non-root switch has only one Root Port per spanning-tree instance.
  • It operates in a forwarding state.

4. Designated Port

  • A Designated Port is the port on a network segment that provides the best path to the Root Bridge.
  • There is one Designated Port per network segment.
  • It operates in a forwarding state.
  • It sends and receives BPDUs for that segment.

5. Alternate (Blocked) Port

  • An Alternate Port provides a backup path to the Root Bridge.
  • It does not forward normal user traffic while in the blocking/discarding state.
  • It continues to receive BPDUs.
  • If the active topology changes, it may transition to a forwarding state.

6. PortFast

  • PortFast allows an access port connected to an end device, such as a server or PC, to move immediately to the forwarding state instead of waiting through normal STP transitions.
  • It reduces the time required for an end device to access the network after the link comes up.
  • PortFast should normally be enabled only on ports connected to end devices, not switch-to-switch links.

Network Topology

Spanning Tree Protocol Network Topology
Fig 1 — Spanning Tree Protocol topology

Root Bridge Election Details

To identify the Root Bridge, use the show spanning-tree command on each switch. Note down the Bridge Priority and MAC Address.

Sl.No Switch Priority MAC Address
1 S1 32769 0060.7094.A032
2 S2 32769 0009.7C16.25EE
3 S3 32769 00D0.9757.60B6
4 S4 32769 0060.47E9.B26A

Since all switches have the same Bridge Priority, the switch with the lowest MAC address becomes the Root Bridge.

Root Bridge: S2 — MAC Address: 0009.7C16.25EE

STP Port Roles and Link Cost

Use show spanning-tree on each switch to identify the Root Port, Designated Port, Alternate Port, and their corresponding costs.

Sl.No Device Port Role Cost
1 S1 Fa0/1 Root 19
Fa0/2 Designated 19
Fa0/3 Alternate (Blocked) 19
2 S2 Fa0/1 Designated 19
Fa0/2 Designated 19
Fa0/3 Designated 19
3 S3 Fa0/1 Root 19
Fa0/2 Alternate (Blocked) 19
Fa0/3 Alternate (Blocked) 19
Fa0/4 Designated 19
4 S4 Fa0/1 Root 19
Fa0/2 Designated 19
Fa0/3 Designated 19

Link Cost Information:

  • S1–S2: Cost 19
  • S1–S3: Cost 19
  • S1–S4: Cost 19
  • S2–S3: Cost 19

Note: STP cost is assigned per interface. The switch calculates the total path cost by adding the costs of the links along the path to the Root Bridge. It is not simply the cost of an entire cable.

Configuration Commands

1. Identify the Root Bridge

Switch 1

enable

! Display STP information
show spanning-tree

! Note the Bridge ID and Root ID
! Compare the Bridge Priority and MAC Address

Switch 2

enable

show spanning-tree

! Check whether this switch is the Root Bridge

Switch 3

enable

show spanning-tree

! Identify the Root Port and path cost

Switch 4

enable

show spanning-tree

! Identify the Root Port and path cost

2. Configure PortFast on Server Port

Switch – Interface Connected to Server

enable
configure terminal

! Select the port connected to the server
interface FastEthernet0/4

! Configure the port as an access port
switchport mode access

! Enable PortFast
spanning-tree portfast

no shutdown

end
write memory

Verification Commands & Outputs

1. Verify Root Bridge

S2# show spanning-tree

VLAN0001
  Spanning tree enabled protocol ieee
  Root ID    Priority    32769
             Address     0009.7C16.25EE
             This bridge is the root

  Bridge ID  Priority    32769
             Address     0009.7C16.25EE

2. Verify Root Port and Link Cost

S1# show spanning-tree

Interface        Role Sts Cost      Prio.Nbr Type
---------------- ---- --- --------- -------- ----------------
Fa0/1            Root FWD 19        128.1    P2p
Fa0/2            Desg FWD 19        128.2    P2p
Fa0/3            Altn BLK 19        128.3    P2p
S3# show spanning-tree

Interface        Role Sts Cost      Prio.Nbr Type
---------------- ---- --- --------- -------- ----------------
Fa0/1            Root FWD 19        128.1    P2p
Fa0/2            Altn BLK 19        128.2    P2p
Fa0/3            Altn BLK 19        128.3    P2p
Fa0/4            Desg FWD 19        128.4    P2p

3. Verify Designated Ports on Root Bridge

S2# show spanning-tree

Interface        Role Sts Cost      Prio.Nbr Type
---------------- ---- --- --------- -------- ----------------
Fa0/1            Desg FWD 19        128.1    P2p
Fa0/2            Desg FWD 19        128.2    P2p
Fa0/3            Desg FWD 19        128.3    P2p

4. Verify STP Summary

S1# show spanning-tree summary
Switch is in rapid-pvst mode
Root bridge for: VLAN0001
PortFast Default is disabled
PortFast Edge BPDU Guard Default is disabled
Portfast Edge BPDU Filter Default is disabled
Loopguard Default is disabled
EtherChannel misconfiguration guard is enabled

5. Verify PortFast Configuration

S1# show spanning-tree interface Fa0/4 detail

Port 4 (FastEthernet0/4) of VLAN0001 is designated forwarding
  Port path cost 19
  Port priority 128, Port Identifier 128.4
  The port is in the portfast mode
  Link type is point-to-point by default
S1# show running-config
interface FastEthernet0/4
 switchport mode access
 spanning-tree portfast

Verification checklist:

  • S2 should be identified as the Root Bridge.
  • Every non-root switch should have one Root Port per STP instance.
  • Designated Ports should be in forwarding state.
  • Alternate Ports should be in blocking/discarding state.
  • Link costs should match the interface speeds and configured STP cost method.
  • PortFast should be enabled on the interface connected to the server.

Important: The verification outputs are illustrative. Actual port roles and costs depend on the physical topology, STP mode, interface configuration, and switch model.

Learning Outcomes

Understood how STP elects a Root Bridge based on Bridge ID, consisting of priority and MAC address.
Learned how link cost is determined by interface bandwidth and how switches use path cost to select the best route to the Root Bridge.
Identified Root Ports, Designated Ports, and Alternate (Blocked) Ports in a switched network.
Understood how STP prevents Layer 2 switching loops by blocking redundant paths.
Learned the difference between forwarding and blocking port states.
Configured PortFast on an access port connected to a server to allow faster transition to forwarding.
Verified STP topology, port roles, link costs, and PortFast configuration using Cisco IOS show commands.

No comments:

Post a Comment