Routing is the process of choosing a path. Every host and router makes a local decision from a routing table; no central brain knows the whole internet.
The routing table
A simple table looks like:
default via 192.168.1.1 dev eth0
192.168.1.0/24 dev eth0
10.10.0.0/16 via 192.168.1.254
For each packet, the host asks: which route matches the destination? If several match, longest prefix wins. A /32 is more specific than a /24, which is more specific than the default /0.
The default gateway
The default route (0.0.0.0/0) is the gateway of last resort. Without it, a host can reach its local subnet and nothing else.
A router forwards a packet by:
- Removing the incoming layer-2 header.
- Looking up the destination IP.
- Rewriting the layer-2 header for the next hop.
- Decrementing TTL and forwarding.
ip route
ip route get 1.1.1.1
traceroute 1.1.1.1
Continue this lesson in the player
A free account unlocks the full lesson, the five-question knowledge check, progress tracking, notes and the completion certificate.