🔍
👶 Kids📝 Blog About Contact 🚀 Get Started Free

Routing & Switching

Understand how switches move data inside a local network, and how routers direct traffic across networks using routing tables and protocols.

The Foundation: LAN vs. WAN

To understand routing and switching, you must know where they happen:

  • Switching happens inside a network (LAN). It uses hardware MAC addresses.
  • Routing happens between networks (WAN/Internet). It uses logical IP addresses.

How Switching Works (Layer 2)

A network switch acts as a smart controller. When a device sends a packet to another device on the same LAN:

  1. The switch inspects the Destination MAC address in the packet header.
  2. It looks at its internal MAC Address Table (or CAM table) to find which port corresponds to that MAC.
  3. If found, it forwards the packet directly to that port.
  4. If not found, it floods the packet to all ports (except the source port) to discover where the target is.

VLANs (Virtual LANs)

Switches can logically segment a single physical switch into multiple virtual networks (VLANs). Devices on different VLANs cannot talk to each other directly without a router, which increases network security and limits broadcast domains.

How Routing Works (Layer 3)

When you send data to a device on a different network (e.g., loading a website):

  1. Your computer realizes the destination IP is outside the local network.
  2. It sends the packet to its Default Gateway (the local router).
  3. The router examines the Destination IP address.
  4. It consults its Routing Table to find the best path.
  5. It forwards the packet to the next hop (another router) closer to the destination.

Routing Tables

A router's map. It contains list entries of destination networks, interface exits, and metrics (cost). Entries are learned in three ways:

  • Directly Connected — Networks physically plugged into the router.
  • Static Routes — Routes manually typed in by a network administrator.
  • Dynamic Routes — Routes learned automatically via routing protocols.

Dynamic Routing Protocols

Routers talk to each other to share network paths using specialized protocols:

  • OSPF (Open Shortest Path First) — An interior gateway protocol (IGP) used inside large corporate networks. Uses Dijkstra's algorithm.
  • BGP (Border Gateway Protocol) — The protocol that binds the global internet together. It routes traffic between ISPs and autonomous systems (AS).
  • RIP (Routing Information Protocol) — An older, simpler protocol based on hop count. Rarely used in modern networks.

What's Next?

See how the physical network layer works by going back to Network Topologies & Hardware, or learn about how security is implemented on these devices in Network Security Basics.