Routers do not ask 'which route seems generally closest?' They compare the destination IP against candidate prefixes and choose the most specific matching route, called longest-prefix match. The selected route then determines the next hop or outgoing interface.
Remember the shape, not the sentence
“Picture a set of nested postal codes. A /8 is a broad region, a /16 is a city, a /24 is a street. If a destination fits multiple regions, the most specific map wins.”
Route anatomy
A route commonly contains a destination prefix and mask, a next hop or directly connected interface, and metadata such as administrative distance or metric depending on the routing system.
Default route
The default route 0.0.0.0/0 matches everything, but it is less specific than any non-default prefix. It is used only when no more-specific route matches.
Longest prefix first
A /24 beats a /16 because the /24 carries more matching bits. Only after the best prefix is identified do protocol-specific metrics or next-hop rules resolve ties within the relevant routing table.
See the mechanism before you memorize it
One diagram, one causal story, one reconstruction task.
Routing tables, default gateway, longest-prefix match — causal map
Receive
Router reads the destination IP from the packet.
Match
Test the destination against candidate prefixes.
Select
Choose the most specific matching prefix.
Next hop
Resolve or use the next-hop forwarding information.
Draw the idea yourself
Rebuild the core flow on a real canvas before moving to the worked walkthrough.
Walk the system
Receive
Router reads the destination IP from the packet.
Match
Test the destination against candidate prefixes.
Select
Choose the most specific matching prefix.
Next hop
Resolve or use the next-hop forwarding information.
Forward
Build the next link-layer frame and send it out the selected interface.
Longest-prefix example
All three routes match 10.20.30.44, but /24 is the most specific and therefore wins.
10.0.0.0/8 → R1
10.20.0.0/16 → R2
10.20.30.0/24 → R3
10.20.30.44 → R3What usually goes wrong
Close the tab. Rebuild it from memory.
Read the question, answer aloud, then reveal.
Why is /24 more specific than /16?Reveal answer
It requires 24 destination bits to match instead of 16, so it describes a smaller set of addresses.
What does a default route do?Reveal answer
It provides a catch-all path when no more-specific route exists.
What happens after route selection?Reveal answer
The router performs forwarding actions such as resolving the next-hop link-layer address and emitting a new frame.
Make this idea travel.
Connect it next to: routing-protocols • nat-ipv6 • subnet-design-lab.