A parcel with only an address
A parcel leaves a warehouse with an address on it and nothing else. No driver knows the whole way.
Each depot only knows which van to put it on next. Step by step, it arrives.
Packets cross the internet in the same way. Each router only decides the next hop.
By the end of this lesson
Note
I can follow a packet across routers.
Key words
| Word | What it means | Example |
|---|---|---|
| Router | a device that passes packets between networks | |
| Routing table | a router's list of networks and where to send each | |
| Next hop | the next router a packet is handed to | |
| Default route | the line used when no other line matches | default via 10.0.1.1 |
| Directly connected | a network the router has a cable on | |
| Hop | one step from one device to the next |
The cells students fill in are left blank in this preview.
A routing table lists networks
Every device with an address has a routing table. Each line names a network and says where to send packets for it.
A host's table is short. It knows its own network, and it has a default route: send everything else to the router.
A router's table is longer. It knows every network it has a cable on.
Read h1's routing table
sudo ip netns exec h1 ip routeShown here, not run. Create a free account to press Run and type it into your own lab’s terminal.
Read r1's routing table
sudo ip netns exec r1 ip routeShown here, not run. Create a free account to press Run and type it into your own lab’s terminal.
What the two tables say
h1 has two lines. default via 10.0.1.1 sends everything to r1. 10.0.1.0/24 dev to-r1 is h1's own network.
r1 also has two lines, 10.0.1.0/24 and 10.0.12.0/24. Both are directly connected. r1 has no line for h2's network, 10.0.3.0/24, and no default route.
The most exact line wins
A packet can match more than one line. The default route matches everything, for example.
The router picks the line with the longest prefix, the biggest number after the slash. That line is the most exact.
If nothing matches and there is no default route, the router drops the packet. It sends back a message: the network is unreachable.
Worked example: a school router's choice
| Packet for | Lines that match | Winner | Next hop |
|---|---|---|---|
| 172.16.4.9 | 172.16.0.0/16, 172.16.4.0/24, default | 172.16.4.0/24 | 172.16.0.2 |
| 172.16.9.9 | 172.16.0.0/16, default | 172.16.0.0/16 | 172.16.0.1 |
| 8.8.8.8 | default | default | 192.0.2.1 |
The cells students fill in are left blank in this preview.
Ping h2 from h1
sudo ip netns exec h1 ping -c 2 -W 1 10.0.3.2Shown here, not run. Create a free account to press Run and type it into your own lab’s terminal.
Trace the packet's hops
sudo ip netns exec h1 traceroute -n -m 4 -w 1 10.0.3.2Shown here, not run. Create a free account to press Run and type it into your own lab’s terminal.
Ask r1 where it would send it
sudo ip netns exec r1 ip route get 10.0.3.2Shown here, not run. Create a free account to press Run and type it into your own lab’s terminal.
Where the packet stops
The ping prints From 10.0.1.1 ... Destination Net Unreachable twice. The message comes from r1, not from h2.
The trace shows one hop, 10.0.1.1, marked !N: network unreachable.
r1 answers RTNETLINK answers: Network is unreachable. Its table has no line for 10.0.3.0/24. Fixing that is the lab.
A common mistake
Warning
Many people think a router knows the whole path to the far end. It only knows the next hop. Every router on the way must have its own line for the far network, and the far side needs a line back for the reply.
Going further: why the reply matters
Once your lab works, run sudo ip netns exec r2 ip route again.
Which line lets r2 send the reply back to h1? Write that line in your assignment's format, add it to a table and test it with your next_hop.