Redundancy without loops: STP/RSTP, edge-port protection and LACP
Explain why Layer 2 loops trigger broadcast storms, trace STP/RSTP root-bridge election and path-cost tie-breaking, protect access and distribution ports with BPDU guard and Root guard, bundle links with LACP and diagnose duplex and MTU faults.
Contentsand lesson path
On this page
- Why it matters
- How STP and RSTP elect a root bridge and protect ports
- Link aggregation with LACP, Linux bridges vs OVS and Layer 2 faults
- Check your understanding
- Apply it
- Review prompt
Lessons of Ethernet Switching & VLANs
- From cable to switch: media, optics, frames, MAC learning and flooding Concept · 25 min
- Lab: a Linux-bridge switch in Containerlab and its forwarding table Lab · 25 min
- VLANs and trunks: tagging, the native VLAN and inter-VLAN routing Concept · 20 min
- Lab: two VLANs, one trunk and a router-on-a-stick Lab · 30 min
- Redundancy without loops: STP/RSTP, edge-port protection and LACP Concept · 25 min
- Check: diagnose four broken layer-2 topologies Knowledge check · 10 questions
What you will learn
- Explain how STP/RSTP elects a root bridge and blocks redundant links, and protect edge ports against loops and rogue switches.
- Bundle links with LACP and diagnose common layer-2 faults: VLAN or native-VLAN mismatch, loops, and duplex or MTU mismatch.
01. Why it matters
Suppose you wire a second trunk between two distribution switches so a severed fibre never drops a floor—and thirty seconds later the entire campus collapses at 100% switch CPU. Or someone plugs an old spare switch into an access closet and core-to-core traffic silently detours through that 1 Gb/s spare.
Unlike IPv4 TTL or IPv6 Hop Limit, an Ethernet frame has no loop counter. Any closed physical Layer 2 loop lets broadcast and unknown-unicast frames circulate endlessly, multiplying in a broadcast storm while switches overwrite MAC tables at line rate (MAC flapping). Redundant Layer 2 topologies need Spanning Tree Protocol (STP/RSTP) to block backup loops or LACP link aggregation to merge parallel cables into one logical link.
02. How STP and RSTP elect a root bridge and protect ports
Classic STP (802.1D) and RSTP (802.1w, integrated into IEEE 802.1Q) prune any physical mesh into a loop-free tree by exchanging Bridge Protocol Data Units (BPDUs). Whereas 802.1D takes 30–50 seconds to recover a link (Max Age 20 s + Listening 15 s + Learning 15 s), RSTP converges in roughly a second on point-to-point links using direct Proposal/Agreement handshakes and three simplified states (Discarding, Learning, Forwarding).
Every switch advertises an 8-byte Bridge ID (BID) combining a configurable priority (default 32768, in multiples of 4096) and its base MAC address. Lower numbers win across four deterministic tie-breaking comparisons in strict order: (1) lowest Root BID, (2) lowest cumulative Root Path Cost, (3) lowest Sender BID, and (4) lowest Sender Port ID. Those four comparisons assign every port's role:
- Elect one Root Bridge (Root BID): All switches compare Root BIDs; the lowest BID becomes Root Bridge. Leaving every switch at default
32768lets whichever switch happens to hold the lowest MAC—often the oldest spare switch in a closet—win the root election and pull cross-building traffic through itself. As a default recommendation, pin your primary core switch to priority4096and secondary backup to8192. - Choose each non-root switch's Root Port (cumulative Root Path Cost, then Sender BID / Port ID): Each non-root switch picks the port with the lowest cumulative root path cost back to the Root—not fewest hops. Using the legacy 16-bit short cost table (
100 Mb/s = 19,1 Gb/s = 4), if a slow 100 Mb/s direct link costs19while two 1 Gb/s hops via a neighbour cost4 + 4 = 8, STP picks the two-hop path of cost8(modern RSTP/802.1Q defaults to 32-bit long costs—100 Mb/s = 200,000,1 Gb/s = 20,000,10 Gb/s = 2,000—with the exact same cumulative rule). Equal-cost ties break on lowest Sender BID, then lowest Sender Port ID. - Choose one Designated Port (DP) per segment and block the rest: On each link, the switch with lower root path cost keeps its port Designated (Forwarding); if both ends have equal cost to the Root, the lower Sender BID wins DP and the peer enters Alternate (Discarding/Blocking). Only one end needs to block to break a loop.
In an equal-cost triangle where S1 is Root and S2 has a lower BID than S3, both S2 and S3 attach directly to S1 via Root Ports, and on the S2–S3 link S2 holds the Designated Port while S3's port toward S2 blocks.
[S1: Root Bridge]
(DP) (DP)
/ \
(RP) (RP)
[S2: lower BID] ---- [S3: higher BID]
(DP) (ALT/Discarding)Protecting access and distribution edges: On a non-edge port facing an end host, RSTP receives no Proposal/Agreement reply and falls back to waiting 2 × forward delay (about 30 seconds), which can time out host DHCP. Enabling PortFast / Edge Port puts host-facing ports straight into Forwarding—but PortFast only skips the listening/learning delay, so a loop can form before STP reacts if a user plugs in an unmanaged switch with two ports patched together. Your switch's own BPDUs loop back through that unmanaged switch, and BPDU guard uses those returning BPDUs to error-disable the port at once. On distribution ports facing downstream switches that legitimately run RSTP, enable Root guard instead: it allows normal BPDUs, but puts the port into a root-inconsistent blocked state if a superior BPDU tries to claim Root Bridge. Finally, Loop guard on Alternate/Blocking uplinks stops a one-way fibre break (where BPDUs vanish) from transitioning the blocked port to Forwarding.
03. Link aggregation with LACP, Linux bridges vs OVS and Layer 2 faults
Because STP keeps backup paths idle, Link Aggregation Control Protocol (LACP, IEEE 802.1AX) negotiates parallel cables into one logical port that STP treats as a single link with zero blocking:
- Modes and member consistency: An
activeport sends LACPDU negotiation probes proactively, whereas apassiveport only responds when it receives LACPDUs. Eitheractive + activeoractive + passivebrings up a bundle, whereaspassive + passivenever forms a bundle. Every member port must match speed, duplex, and trunk/allowed/native VLAN configuration; pairing static mode"on"(no LACP) on one switch with LACP on the partner causes the LACP side to suspend the ports (or risks a loop if STP is disabled). - Configuring and verifying on Linux (Linux bonding): Create an
802.3adbond (ip link add bond0 type bond mode 802.3ad miimon 100 xmit_hash_policy layer3+4), enslave member links (take each one down first, because the kernel refuses to enslave an interface that is up:ip link set eth1 down && ip link set eth1 master bond0, the same foreth2, thenip link set bond0 up), and inspect negotiation state withcat /proc/net/bonding/bond0orip -d link show bond0(orshow port-channel summaryon a switch). - Why one TCP stream still hits one link's ceiling: LACP hashes packet headers (MACs, IPs, and TCP/UDP ports via
layer3+4) so every packet of a single flow stays on one physical cable to avoid TCP out-of-order delivery. Two 10 Gb/s bundled trunks deliver ~10 Gb/s to one file transfer and ~20 Gb/s aggregate across multiple concurrent flows.
Linux bridge STP vs Open vSwitch (OVS) and when not to use STP: On Linux, ip link add br0 type bridge stp_state 1 priority 4096 enables kernel 802.1D STP (bridge link set dev <p> guard on / root_block on), whereas Open vSwitch (ovs-vsctl) adds programmable OpenFlow tables, RSTP, and LACP bonds widely used on KVM hypervisors and Containerlab OVS labs. When not to use STP at all: Multi-switch spanning trees scale poorly in large data centres because half the capacity sits blocked and broadcast faults span racks; modern leaf-spine fabrics replace STP triangles with Layer 3 ECMP routing or switch-pair MLAG (explored in IP Routing and Network Design).
Triaging duplex and MTU mismatches: Two sneaky Layer 2 faults mimic slow links without dropping link light:
- Duplex mismatch: Forcing
full duplexon one port disables auto-negotiation, so its peer falls back tohalf duplex. The half-duplex side logs late collisions, while the full-duplex side logs CRC errors. Restore auto-negotiation on both sides (or force both identically). - MTU mismatch: Because TCP MSS negotiation clamps segment sizes whenever either peer uses MTU 1500, the silent stall happens when both endpoints use MTU 9000 (negotiating an ~8,960-byte MSS) with a 1,500-byte switch port between them: small
pingchecks pass and CRC/collision counters stay at zero, yet large TCP transfers stall right after handshake because Layer 2 switches drop oversized frames silently instead of fragmenting them (often logginggiantsoroversizeinput error counters).
04. Check your understanding
05. Apply it
Design the recovery test for this skill's full practice exercise: connect two vlan_filtering 1 Linux bridges (or OVS switches) with two parallel 802.1Q trunks carrying VLANs 10 and 20 plus a router-on-a-stick, enable STP (ip link set br0 type bridge stp_state 1 priority 4096), confirm with bridge -d link show which parallel link enters blocking, then set mismatched native VLAN PVIDs on one trunk end and trace the cross-VLAN leak.
From here, continue to Wireless LAN Fundamentals, Packet Capture Analysis, or Network Design to see how switched domains integrate with Wi-Fi and routed cores.
06. Review prompt
Explain the four STP tie-breaking criteria from Root BID to Sender Port ID, distinguish PortFast, BPDU guard, Root guard, and Loop guard, explain LACP active/passive negotiation and why it hashes per flow rather than per frame, and contrast duplex-mismatch counters with MTU-mismatch symptoms.
References
Your progress
Reading state
Sign in to save that you finished reading this lesson.
Prove this skill
10 questions · about 8 minutes · scored automatically. Marking a lesson as read never demonstrates a skill.