Overview
Curated: · Written: · Reviewed:
Routing & Switching Fundamentals
In one line
Switching forwards frames by destination MAC inside one VLAN. Routing forwards packets by longest-prefix match across IP prefixes. Switch when the destination shares the sender's subnet; route when it does not.
Key definitions
- CAM table: maps a MAC address to a port within a VLAN. A miss floods.
- FIB: the forwarding table the data plane uses, programmed from the RIB.
- Administrative distance (AD): ranks route sources for the same prefix; lower wins. Cisco defaults: connected 0, static 1, eBGP 20, OSPF 110, iBGP 200.
- DR/BDR: the OSPF hub elected on a multi-access segment. Non-DR routers reach Full only with the DR and BDR.
- AS_PATH: the BGP attribute listing traversed ASes. A router rejects any path that already contains its own AS.
- Native VLAN: the VLAN sent untagged over an 802.1Q trunk. Both ends must match.
How it works
- A switch learns the source MAC and ingress VLAN, forwards known unicast to the learned port, and floods unknown unicast and broadcast within the VLAN.
- For an off-subnet destination, the host ARPs for its gateway and frames carry the gateway's MAC. The router strips the Layer 2 header, runs longest-prefix match in the FIB, decrements TTL, and rewrites the Layer 2 header. IP addresses stay constant.
- OSPF neighbors progress Down, Init, 2-Way, ExStart, Exchange, Loading, Full. Hello and dead timers must match; the broadcast and point-to-point defaults are 10 s and 40 s. Every non-backbone area attaches to Area 0, and inter-area routes transit it.
- BGP is a path-vector protocol. Routes learned from eBGP go to iBGP peers, but routes learned from one iBGP peer are not passed to another. A full iBGP mesh, or route reflectors, avoids that gap.
When to use and when not to
| Choice | Use when | Avoid when |
|---|---|---|
| Switching within one VLAN | Hosts share a subnet | The destination is off-subnet |
| Router-on-a-stick | Few VLANs, light inter-VLAN traffic | All inter-VLAN traffic crosses one bottleneck link |
| SVI on a Layer 3 switch | Campus inter-VLAN routing at line rate | The device lacks Layer 3 hardware forwarding |
| Routed port | Point-to-point links between Layer 3 devices | You need many subnets on one interface |
| Static route | Stub networks, or a default with a clear owner | The next hop may fail, since a static route never withdraws |
| Summary route | Contiguous prefixes behind one ABR or ASBR | Address space is fragmented, or the summary hides a missing specific |
| OSPF | Paths must reconverge within one administrative domain | A single exit where the protocol adds state for no benefit |
| BGP | Policy between autonomous systems | Simple single-homed sites |
| LAG | More aggregate capacity and member-link redundancy | You need one flow faster than one member link |
Traps interviewers probe
- Reading a populated MAC table as end-to-end reachability. It proves only local reachability in the VLAN. Fix: check the gateway's ARP entry, the route to the destination, and the return path.
- Saying a static route always wins. It wins only when prefix length ties. Fix: a longer prefix from any protocol wins first, because prefix length is compared before AD.
- Comparing metrics across protocols. Fix: AD picks the source; metric only ranks routes within one protocol.
- Assuming LAG prevents loops, or that a 4 x 10 Gbps LAG gives one flow 40 Gbps. The bundle looks like one link to STP, so STP still runs. Each flow hashes to one member, so a single flow tops out at 10 Gbps. Fix: keep STP on, use BPDU guard on edge ports, and match member speed, VLAN and system ID.
- Assuming a native VLAN mismatch is loud. It is silent and can merge VLANs or drop traffic. Fix: match the native VLAN on both ends and move it off VLAN 1 to an unused VLAN.
Interview tips
Opening: Name the plane first, then the table: "I'll walk the packet from the host and check the table that decides each hop."
Likely follow-ups:
- How does AD differ from metric?
- Why does a summary route of 10.0.0.0/22 cover 10.0.0.0/24 through 10.0.3.0/24, and what breaks if one /24 is unreachable?
- Why does an OSPF neighbor stall in ExStart?
- Why does iBGP need a full mesh?
- How would you prove the FIB matches the RIB after a change?
30-second outline:
- Same subnet means the MAC table decides; different subnet means longest-prefix match decides.
- Say what changes per hop: IP addresses stay, MAC addresses are rewritten, TTL drops by one.
- Name the three states to compare: the MAC entry or route, the RIB route, and the FIB entry.
- Give the likeliest fault for the symptom: a missing gateway ARP entry, a mismatched OSPF timer or MTU, a missing iBGP mesh session, or a native VLAN mismatch.
- Say how you would confirm it: the table entry or counter at the failing hop.
Feedback on this overview
Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.