Tech_Interview_Prep

Routing & Switching Fundamentals

How traffic gets forwarded within a local network (switching) versus across different networks (routing).

What it is

Switching forwards traffic within a single local network based on hardware (MAC) addresses; routing forwards traffic between different networks based on IP addresses — different problems solved at different layers.

Key points

  • Switching (Layer 2): a switch learns which device is on which port by MAC address and forwards frames directly to the right port — efficient, but only works within one local network segment.
  • Routing (Layer 3): a router forwards packets between different networks based on IP address, using a routing table to decide the next hop — this is what lets traffic cross from one network to another, ultimately across the internet.
  • Routing protocols: dynamic routing protocols (like BGP for the internet's core routing, or OSPF within an organization) let routers automatically learn and share reachability information, rather than requiring every route to be manually configured.
  • VLANs: let a single physical switch infrastructure be logically segmented into multiple separate broadcast domains — a common way to isolate traffic (e.g. separating a guest network from an internal one) without separate physical hardware.