how/network
How does a packet reach Google from your laptop in 10-15 hops? Each router knows only "where to pass it next", and that is enough.
When you ping 8.8.8.8, the packet passes through 5-15
routers before it reaches Google. Odd: the internet
is huge, so how do routers manage to "know the way"?
The simple answer: nobody knows "the whole map of the internet". Each router knows only its own little piece: "network X is on my interface Y, and everything else, hand it to that neighbor over there". This hop-by-hop logic is what makes the internet scale.
Press ▶ to watch one packet pass through 3 routers, how each of them makes a decision, and why TTL must be decremented.
A client with IP 10.0.0.5 wants to send a packet to
203.0.113.45. The stack looks in the routing-table:
10.0.0.0/24 dev eth0, our networkdefault via 10.0.0.1, everything else goes through gateway R1The address 203.0.113.45 does not fall under our /24, so we use the
default-gateway. The packet leaves for R1 with a starting TTL=64
(the Linux default).
recap
What to remember:
/24 beats /16, /16 beats /0ip route. You can play with routes
without a reboot: add one with ip route add, remove one with ip route delIf you want to get your hands on it, there is a lab where a topology of 3 nodes is built and the packet travels through them with tcpdump observation.