Routing Basics

Networking Fundamentals

Chapter 6 · Routing Basics

net1-5 covered how to tell whether an address is on your own subnet. This chapter covers what happens the moment it isn't — how a packet actually finds its way to a network your device has never directly touched.

The Core Problem Routing Solves

A device already knows how to deliver a packet locally — same subnet, direct Data Link-layer delivery (net1-2/net1-3). Routing exists specifically for the moment the destination isn't local: something has to decide where that packet goes next.

The Default Gateway — What It Actually Does

When a device wants to reach an address outside its own subnet, it doesn't guess a path — it hands the packet to its default gateway, almost always a router, which takes on the job of figuring out the next step.

Concretely: the device compares the destination IP against its own subnet mask (net1-5's own math). If the destination falls outside the local subnet, the packet gets addressed at the Data Link layer to the default gateway's own MAC address — but the destination IP address itself, at the Network layer, stays completely unchanged. The gateway is only the next physical hop, not the final destination.

This is the formal answer to the term left unexplained since net1-1, and it's exactly what net1-4's own home router example was doing all along — the router is the default gateway for every device behind it.

Routing Tables — How a Router Decides Where Next

A routing table is a list of rules of the form "to reach network X, send packets to next-hop Y." Every router consults its own table for every packet it forwards.

Destination Next hop Interface 192.168.1.0/24 directly connected eth0 192.168.2.0/24 10.0.0.2 eth1 0.0.0.0/0 10.0.0.1 eth1 # the default route — "everything else"

When more than one route could match a destination, the most specific one wins — this is called longest prefix match: the entry with the largest CIDR number (the most specific subnet) is preferred over a broader, more general route.

Static vs. Dynamic Routing

Static routing means someone manually configures each route ahead of time — simple and predictable, but it doesn't adapt automatically to network changes or failures. Reasonable for a small network with few, stable paths.

Dynamic routing means routers exchange information with each other using routing protocols (RIP, OSPF, and BGP are the real, named examples — none of them deep-dived here, that's genuinely out of this course's scope) to automatically learn the network's topology and reroute around failures. BGP specifically deserves a brief, honest mention: it's the literal protocol that routes traffic across the entire internet, between the independently-run networks (Autonomous Systems) that make up the "network of networks" net1-1 opened with.

A Worked Example — Tracing a Packet Across Two Subnets

Device A (192.168.1.42/24) wants to reach Device B (192.168.2.10/24) — a genuinely different subnet. Device A checks whether 192.168.2.10 falls within its own 192.168.1.0/24 subnet — it doesn't, so the packet is sent to Device A's default gateway. The gateway checks its own routing table, finds a route to 192.168.2.0/24, and forwards the packet out the correct interface toward Device B's subnet, where local delivery takes over again.

Setup effortAdapts to failure?Typical use case
StaticManual, per routeNo — requires manual reconfigurationSmall, stable networks with few paths
DynamicAutomatic once configuredYes — routers exchange updatesLarge or changing networks; the internet itself (BGP)
Seeing your own device's routing table
ip route on Linux or route print on Windows shows a device's real routing table, including its own default gateway entry — the exact mechanism this chapter describes, made visible. net1-10 revisits this alongside other diagnostic tools.
The default gateway is a single point of failure for everything off-subnet
A genuinely common, confusing real-world scenario: "I can reach my neighbor's device on the same subnet, but not google.com." If the default gateway is misconfigured or down, every off-subnet destination becomes unreachable — while local, same-subnet traffic keeps working perfectly fine, since it never needed the gateway in the first place. The symptom (some things work, others don't) can look mysterious until the gateway itself is checked directly.

Hands-On Exercises

Exercise 1

A device on 10.0.1.0/24 wants to reach 10.0.9.5. Using this chapter's own step-by-step logic, explain exactly what the device does before the packet ever leaves it.

📄 View solution
Exercise 2

A router's routing table contains both a route to 192.168.2.0/24 and a default route (0.0.0.0/0). A packet destined for 192.168.2.55 arrives. Using this chapter's own longest-prefix-match rule, explain which route wins and why.

📄 View solution
Exercise 3

A user reports they can access every device on their own home network but can't reach any website. Using this chapter's own warn-box, explain the most likely cause and why local devices still work fine.

📄 View solution

Chapter 6 Quick Reference

  • Routing only matters once a destination is off the local subnet — local delivery needs no routing at all
  • Default gateway — the router a device hands off-subnet traffic to; only the next hop, never the final destination
  • Routing table — "to reach network X, send to next-hop Y," consulted for every packet
  • Longest prefix match — the most specific matching route (largest CIDR number) always wins
  • Static routing — manual, predictable, doesn't adapt to failure
  • Dynamic routing — routers exchange updates automatically; BGP specifically routes the entire internet between Autonomous Systems
  • A dead or misconfigured default gateway breaks everything off-subnet while local traffic keeps working — a classic, confusing symptom pattern