Here are practical configuration examples for enabling and configuring Spanning Tree Protocol on Cisco switches:
Basic STP Configuration
# Enter global configuration mode
Switch> enable
Switch# configure terminal
# Enable Spanning Tree (enabled by default on Cisco)
Switch(config)# spanning-tree mode pvst
# Options: pvst (Per-VLAN STP), rapid-pvst, mst
# Set bridge priority to influence root bridge election
# Lower priority = more likely to become root (default: 32768)
Switch(config)# spanning-tree vlan 1 priority 4096
# Priority must be in increments of 4096 (0-61440)
# Or use shortcut to make this switch root
Switch(config)# spanning-tree vlan 1 root primary
# Configure port cost (influences path selection)
Switch(config)# interface gigabitEthernet 0/1
Switch(config-if)# spanning-tree cost 4
Switch(config-if)# exit
# Configure port priority (lower = preferred)
Switch(config)# interface gigabitEthernet 0/2
Switch(config-if)# spanning-tree port-priority 64
Switch(config-if)# exit
Rapid STP (RSTP) Configuration
# Enable Rapid Per-VLAN Spanning Tree
Switch(config)# spanning-tree mode rapid-pvst
# Configure PortFast for access ports (skips listening/learning)
Switch(config)# interface fastEthernet 0/5
Switch(config-if)# spanning-tree portfast
Switch(config-if)# exit
# Enable BPDU Guard (shuts port if BPDU received)
Switch(config)# interface fastEthernet 0/5
Switch(config-if)# spanning-tree bpduguard enable
Switch(config-if)# exit
Verification Commands
# View spanning tree status
Switch# show spanning-tree
# View STP for specific VLAN
Switch# show spanning-tree vlan 1
# View brief summary
Switch# show spanning-tree summary
# View root bridge information
Switch# show spanning-tree root
# View interface STP details
Switch# show spanning-tree interface gigabitEthernet 0/1
# View STP topology changes
Switch# show spanning-tree detail
Sample Output
Switch# show spanning-tree vlan 1
VLAN0001
Spanning tree enabled protocol ieee
Root ID Priority 4097
Address 0019.e86a.6f80
This bridge is the root
Bridge ID Priority 4097
Address 0019.e86a.6f80
Interface Role Sts Cost Prio.Nbr Type
---------------- ---- --- --------- -------- ----
Gi0/1 Desg FWD 4 128.1 P2p
Gi0/2 Desg FWD 4 128.2 P2p
Key Status Codes:
- FWD = Forwarding
- BLK = Blocking
- LRN = Learning
- LIS = Listening
These configurations ensure your network has loop prevention while maintaining redundancy!
No comments:
Post a Comment