Labs / First Contact / IP addressing & subnets

Lab 3 of 4 ยท IP addressing & subnets

Addresses and subnets: on my network, or through the router?

Subnetting practice: read what a prefix means, then watch a wrong one break the network.

Start this lab, free Free 6 steps

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.

The prefix is a line through the bits
The prefix is a line through the bits
Out through the router, back direct
Out through the router, back direct

Steps

  1. An address and its network

    Alice's IP address is 10.0.1.10/24, and the /24 says which addresses are her neighbours: every 10.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
  2. 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
  3. 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
  4. 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.200 falls with a /26, then see /25 and /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
  5. A prefix too long: the detour

    A wrong prefix is a common typo, and its symptom is subtle. Break it: give alice /25 instead 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
  6. 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

Run these steps on real machines

Learn it on real machines.

Every lab is a small network of real Linux machines in your browser. Start with a free account: Google or email, no card.

Start this lab, free