Routing and Switching
VLANs and trunking
An 802.1Q trunk inserts a 4-byte tag, reducing usable MTU to 1496 and reserving a VLAN ID field of 12 bits (1–4094 usable). The native VLAN is sent untagged on 802.1Q links; a mismatch does not bring the trunk down, it silently merges two broadcast domains and leaks traffic across VLANs. Access ports belong to one VLAN and should never see tags.
Spanning Tree
Root bridge election uses the lowest bridge ID: priority first (default 32768, adjusted in increments of 4096) then the lowest MAC. RSTP converges in the sub-second range using proposal/agreement rather than timers. BPDU Guard errports an access port that receives a BPDU; Root Guard blocks superior BPDUs on ports facing away from the root.
Forwarding decisions
Switching is MAC-table lookup with flooding for unknown unicast. Routing applies longest prefix match first, then administrative distance among candidates for the same prefix, then metric. Reference distances: connected 0, static 1, eBGP 20, EIGRP 90, OSPF 110, RIP 120, iBGP 200.
OSPF and BGP essentials
OSPF builds adjacencies, elects DR/BDR on broadcast segments, and floods LSAs within an area; all areas must touch area 0. BGP selects paths by weight, local preference, locally originated, AS_PATH length, origin, MED, then eBGP over iBGP. eBGP peers are usually directly connected with TTL 1; iBGP requires full mesh or route reflectors.
Worked example
A router learns 10.1.0.0/16 via OSPF and 10.1.4.0/24 via a static route. Traffic to 10.1.4.9 follows the static route, because longest prefix match is evaluated before administrative distance - distance only breaks ties between identical prefixes. Naming OSPF distance 110 as the reason is the classic wrong answer.
Traps that cost marks
Comparing AD across different prefix lengths, forgetting floating statics use a raised distance, expecting a native VLAN mismatch to raise a link-down alarm, and configuring STP priority as an arbitrary number instead of a multiple of 4096.