This is the feature that prevents infinite layer 2 loops among redundant links leading to broadcast storms.
SW3#show spanning-tree
VLAN0001
^Show who the root bridge is, this switch/bridge's
priority, root status, role (designated, non-designated), and port cost
for each interface.
SW3#show spanning-tree vlan 1
^Filter the output to only show vlan 1
SW3#show spanning-tree detail
Reveal more details
Shorter overall view but displays number of ports in various states:
SW3#show spanning-tree summary
NAME Blocking Listening Learning Forwarding STP Active
VLAN0001 0 0 0 4 4
Portfast is a feature that lets a a switch interface skip the listening/learning stages and go straight to forwarding state. The idea here is that the interface is connected to a PC, not a switch. If it isn't connected to a switch, there is no danger of a layer 2 infinite loop.
[Seems risky]
SW1(config-if)#spanning-tree portfast
^Enables portfast
SW1(config)#spanning-tree portfast default
^Enables portfast on all access ports by default
BPDU Guard makes this less risky. If an interface enabled with BPDU guard receives a BPDU from another switch, the interface will be shut down to prevent a loop from forming:
SW1(config)#int g0/2
SW1(config-if)#spanning-tree bpduguard enable
^Turns on BPDU guard for a single interface
SW1(config)#spanning-tree portfast bpduguard default
^Turns on BPDU guard by default
SW1(config)#spanning-tree mode ?
^Configures which spanning-tree mode the switch uses:
mst Multiple spanning tree mode
pvst Per-Vlan spanning tree mode (Classic with Cisco's per Vlan addition)
rapid-pvst Per-vlan rapid spanning tree mode (Modern and improved per-Vlan spanning tree mode)
Rig a specific switch to act as the root bridge for vlan 1:
SW3(config)#spanning-tree vlan 1 root primary
^This command figures out the next lower priority (4096 less) for you so you don't have to calculate it.
SW2(config)#spanning-tree vlan 1 root secondary
^Rig up a specific switch to act as a secondary.
Spanning Tree Costs:
STP - Cost
10 Mbps - 100
100 Mbps - 19
1 Gbps - 4
10 Gbps - 2
[These are my notes from Jeremy's excellent CCNA course which can be viewed here.]