Choose a route for a packet
Follow next hops and understand longest-prefix matching.
- Select the most specific matching route for a destination.
- Explain how the TTL prevents routing loops.
- Read a traceroute and explain how it discovers a path.
No router knows the whole path to a destination. Each one makes a single local decision: which neighbor gets this packet closer? The packet then repeats the question at every hop. This is why the Internet survives failures so well. There's no central map to break, just many tables that can be updated independently.
The forwarding table
A router's table lists destination prefixes and next hops. Several entries can contain the same address, because prefixes nest inside each other. The rule that settles it is longest-prefix match: the most specific route wins. The order of the table doesn't matter.
The route 0.0.0.0/0 has zero network bits, so it matches everything. It's the default route, the fallback that only wins when nothing more specific does.
Try it
Up to 15 XPYou are the router
For each packet, click the route you would use. Several may contain the address. Before you click, check every row: does the address fall inside this prefix? Then pick the longest one that does.
Packet for 10.1.2.8
What a router looks like at scale
Your home router has a handful of routes. On the Internet’s backbone, the same decision happens on much bigger machines, in buildings where networks meet.

Carrier router
InternetForwards traffic between large networks, using dedicated chips to look up routes at full speed.
How it fits: It runs longest-prefix match just like you did, against a table of hundreds of thousands of routes learned through BGP.
How to spot it: A big chassis of slide-in cards connected by fiber.

Internet exchange
InternetA site where many networks connect to shared switches and hand traffic to each other directly.
How it fits: When traceroute shows a hop at an exchange point, your packet passed through a room like this one.
How to spot it: Rows of cabinets joined by large amounts of yellow fiber.
Photo: Kirsten Bucher, CC BY-SA 3.0 de, adapted
Your own machine has a routing table
Every computer routes, not just routers. ip route prints the table (route print on Windows), and ip route get tells you which entry a destination would use.
1$ ip route
2default via 192.168.1.1 dev wlan0
310.8.0.0/24 dev tun0
4192.168.1.0/24 dev wlan0
5
6$ ip route get 10.8.0.5
710.8.0.5 dev tun0 src 10.8.0.2What stops packets circling forever?
Tables can briefly disagree, for example while a failed link is being routed around. Router A may send a packet to B while B sends it back to A. Every IP packet therefore carries a TTL (time to live; IPv6 calls it the hop limit). Each router lowers it by one, and at zero the packet is dropped and an ICMP Time Exceeded message goes back to the sender.
That error message enables a clever tool: send a packet with a TTL of 1 and the first router reports back. Send a TTL of 2 and the second one does. That's traceroute.
Try it
Up to 15 XPDiscover a path with traceroute
Send probes with a rising TTL and watch the path appear one router at a time. Look at the chart as it grows. Where does the time jump, and what could explain that?
- You
- ?
- ?
- ?
- ?
- ?
- ?
- ?
$ traceroute learn.example
Try it
Up to 15 XPRead real routing output
Click the line that answers each question. In ip route, default means 0.0.0.0/0.
Which route carries a packet to 10.8.0.5?
Key takeaways
Each router makes one local decision, and the next hop repeats it.
Longest-prefix match picks the most specific route, and the default route is the last resort.
The TTL stops loops, and traceroute uses it to reveal a path.
Lesson quiz
7 questions · pass with 5 correct · up to 50 XP
Passing this quiz completes the lesson and keeps your streak going. Questions you miss come back in review sessions later.
Questions about this lesson
Stuck? Ask. Figured something out? Share it. Explaining is one of the best ways to learn.
Loading posts…