Card 01/ 10

ConceptDifficulty: Beginner2 min

Routers and Routing Tables

A router looks up the destination address in a table and forwards the packet one hop closer.

A router forwards each packet by looking up its destination IP address in a routing table, a list of address ranges and where to send packets for each. The router does not know the whole path; it only knows the next hop, the next router or machine to hand the packet to, and every router on the way makes the same decision again.

Picture a small office router with two networks plugged into it, one for staff and one for guests, and a line to the internet provider. A packet arrives for 10.0.20.15. The router does not trace a route across the world. It checks its table, finds that 10.0.20.0/24 is the guest network on its second port, and sends the packet out of that port. A packet for a website goes out of the line to the provider, whose own router decides again.

A small office router's routing table
DestinationNext hopInterfaceMeaning
10.0.10.0/24Directly connectedPort 1Staff network; deliver on the link
10.0.20.0/24Directly connectedPort 2Guest network; deliver on the link
10.8.0.0/1610.0.10.254Port 1Branch office, through the VPN router on the staff network
0.0.0.0/0198.51.100.1Internet lineEverything else: the default route, to the provider

Each row has three parts. The destination is a range in CIDR form. The next hop is the address of the router to hand the packet to, or "directly connected" when the destination is on one of the router's own links. The interface is the port to send it out of.

The last row is the default route, written 0.0.0.0/0. A /0 prefix has no network bits, so every address matches it. It catches every packet no other row claims, which is how a small router can reach the whole internet with one line: it hands everything it does not know to a router that knows more.

Rows come from three places: networks the router is attached to, routes an administrator typed in, and routes learned from other routers through a routing protocol.

Each router decides on its own, with no memory of the path a packet has taken so far. If two routers each think the other is the way to a network, a packet bounces between them; a hop counter in the IP header, the TTL, makes sure it eventually dies instead of circling forever.

So when traffic goes somewhere unexpected, read the routing table of the last router it reached: the row it matched explains where it went.

← → move through sections and cards