The idea
On a small office network, alice, bob and a printer share one wire with officeRouter, the router to a file server on another network. Alice reads her own prefix to decide: on my network, or through the router? Subnetting practice, one prefix at a time.
Steps
-
An address and its network
Alice's IP address is
10.0.1.10/24, and the/24says which addresses are her neighbours: every10.0.1.x. Knowing exactly where her network starts and ends is what lets her decide. Ask a calculator what else it says.alice:~# ipcalc -npbm 10.0.1.10/24
-
Direct, or via the router
The prefix matters because it picks the route a packet leaves by: straight to a neighbour, or to the router. Ask alice how she would reach bob (
10.0.1.11), then the file server (10.0.2.10).alice:~# ip route get 10.0.1.11 alice:~# ip route get 10.0.2.10
-
See the router in the path
A decision in a table is only a plan; real traffic proves it. Traceroute lists every router a packet passes on its way. Trace the file server, then bob.
alice:~# traceroute -n 10.0.2.10 alice:~# traceroute -n 10.0.1.11
-
Prefix arithmetic
A longer prefix means a smaller network, which is how one block is cut into several. Work out where the printer's
10.0.1.200falls with a/26, then see/25and/30.alice:~# ipcalc -nbm 10.0.1.200/26 alice:~# ipcalc -nbm 10.0.1.200/25 alice:~# ipcalc -nbm 10.0.1.200/30
-
A prefix too long: the detour
A wrong prefix is a common typo, and its symptom is subtle. Break it: give alice
/25instead of/24, then trace the printer,10.0.1.200, on her own wire.alice:~# ip addr add 10.0.1.10/25 dev eth0 alice:~# ip addr del 10.0.1.10/24 dev eth0 alice:~# traceroute -n 10.0.1.200
-
A prefix too short
Now the other way, the typo that hurts more: give alice the same address with
/16, and ping the file server. Then find the fix yourself.alice:~# ip addr add 10.0.1.10/16 dev eth0 alice:~# ping -c2 10.0.2.10 alice:~# ip addr del 10.0.1.10/16 dev eth0 alice:~# ping -c1 -W2 10.0.2.10