Jeremy’s IT Lab lecture video:
Day 20 - Spanning Tree Protocol (STP) (1)
Commands
Commands List
Spanning Tree Show Commands
6. Spanning Tree
Link to original
- show spanning-tree
-->
Shows general STP status and information- show spanning-tree vlan vlan-id
-->
Shows spanning-tree information for a specific VLAN- show spanning-tree detail
-->
Shows detailed STP information- show spanning-tree summary
-->
Shows a summary of the current STP configurationSpanning Tree Interface Commands
Spanning Tree
1. General
- spanning-tree mode mode {mst
/
pvst/
rapid-pvst} (Versions)2. Spanning Tree Portfast / BPDU Guard
- spanning-tree portfast
-->
Enables portfast on the current interface.- spanning-tree portfast default
-->
Enables Portfast on all access ports by default.- spanning-tree bpduguard enable
-->
Enables BPDU Guard on the current interface.- spanning-tree portfast bpduguard default
-->
Enables BPDU Guard on all Portfast-enabled interfaces by default.3. Spanning Tree VLAN Related
- spanning-tree vlan vlan-id root primary
-->
Sets the STP bridge priority to 24576 (Or 4096 lower than the current lowest STP priority.)- spanning-tree vlan vlan-id root secondary
-->
Sets the STP bridge priority to 28672- spanning-tree vlan vlan-id cost number
-->
Changes the interface’s STP root cost- spanning-tree vlan vlan-id port-priority number
-->
Changes the interface’s port priority4. Spanning Tree Link Type
Link to original
- spanning-tree link-type type { point-to-point
/
shared }
Spanning Tree Protocol (STP) Info
Redundancy is an important part of modern network design, and the Spanning Tree Protocol (STP) was made to help with that.
Broadcast Storms
The Ethernet frame doesn’t have a Time-To-Live (TTL) field. Therefore, when a switch sends out a broadcast/unknown unicast message, to a network with a lot of switches, there’s a chance the messages will keep looping. Eventually, there will be a lot of looping broadcasts in the network which will lead to congestion in the network making it unusable for legitimate traffic. This is called a broadcast storm
Network congestions leads to MAC Address Flapping. Each time a frame arrives on a switchport, the switch uses the source MAC address to update its MAC address table. When frames with the same source MAC address repeatedly arrive on different interfaces, the switch is continuously updating the interface the interface in its MAC address table, which leads to MAC Address Flapping.
Classic Spanning Tree Protocol
The ‘Classic Spanning Tree Protocol’ is IEEE 802.1D. Switches from all vendors run STP by default.
- STP prevents loops by placing redundant ports in a blocking state. These become disabled interfaces which can enter a forwarding state if a currently forwarding interface fails.
- Forwarding interfaces send and receive all normal traffic as well as Bridge Protocol Data Units (BPDUs).
- Blocking interfaces only send or receive STP messages called Bridge Protocol Data Units (BPDUs).
- By selecting forwarding and blocking ports, STP creates a single path to/from each point in the network. This prevents Layer 2 loops.
- STP-enabled switches send/receive Hello BPDUs out of all of their interfaces every 2 seconds (default timer).
- If a switch receives a Hello BPDU on an interface, it knows that the interface its connected to belongs to another switch, as end hosts don’t use STP and therefore don’t send Hello BPDUs.
Bridge Protocol Data Unit
Switches use one field in the STP BPDU, the Bridge ID field, to elect a root bridge for the network.
The switch with the lowest Bridge ID becomes the root bridge. All ports on the root bridge must be in a forwarding state in each collision domain, and other switches must have a path to the root bridge.
![]() |
---|
Bridge ID Field |
- The bridge priority is 32768 by default.
- The STP bridge priority can only be changed in units of 4096.
- If all switches have the same bridge priority, the lowest MAC address becomes the root bridge.
- (The Bridge Priority is compared first, if they tie, then the MAC address is used as a tie-breaker)
- For Cisco switches, they use a version of STP called PVST (Per-VLAN Spanning Tree) which runs a separate STP instance in each VLAN, so in each VLAN, different interfaces could be either forwarding or blocking.
- To calculate the total bridge priority, we add up the bridge priority and the extended system ID (VLAN ID).
Every switch assumes it’s the root bridge when it is powered on, and it will only give up that status if it receives a superior BPDU (a lower bridge ID)
Only the root bridge sends the BPDUs, other switches in the network will forward them, but not generate their own.
Spanning Tree Root Costs & Port Priority
The port priority of all interfaces is 128.interface-id by default.
- Ex: Interface G0/1 would have a default port priority of 128.1
The Process of Assigning Ports in Spanning Tree
- One switch is the root bridge, and all the ports on it are designated ports (forwarding state)
- Root bridge selection is done through:
- Lowest bridge ID
- Root bridge selection is done through:
- Remaining switches will select one root port (forwarding state). Ports across from the root port are ALWAYS designated ports
- Root port selection is done through:
- Lowest root cost
- Lowest neighbor bridge ID
- Lowest neighbor port ID
- Root port selection is done through:
- Each remaining collision domain will select one designated port (forwarding state) and one non-designated port (blocking state)
- Designated port selection is done through:
- Interface on switch with lowest root cost
- Interface on switch with lowest bridge ID
- Designated port selection is done through: