The number after the slash splits an address into a network number and a host number within it. It tells you who is a neighbour and who is not.
An IPv4 address is 32 bits written as four numbers from 0 to 255. A prefix of /24 means the first 24 bits are the network number, that is, the first three numbers. The last number is the host number.
Addresses with the same network number form a subnet. It is written as an address ending in zero: 192.0.2.0/24 covers the addresses from 192.0.2.0 to 192.0.2.255. The first and the last are reserved, and hosts get .1–.254.
| Address | Subnet |
|---|---|
192.0.3.10/24, the client |
192.0.3.0/24 |
192.0.2.1/24, the server |
192.0.2.0/24 |
Neighbours in a subnet exchange packets directly. To send a packet into another subnet, the kernel needs a route there. With no route, ping prints Network is unreachable at once and sends nothing.
The "first three numbers match" rule holds only for /24. A /25 prefix splits the same 256 addresses in half: .0–.127 and .128–.255.
The addresses 192.0.2.x, 198.51.100.x and 203.0.113.x are reserved for examples: they do not exist on the internet, so the practice network clashes with nothing.
Which address should lab0 get so that the server 192.0.2.1/24 becomes the client's neighbour?
-
That is the server's own address. A client holding it will answer
ping 192.0.2.1by itself, and the request will never reach the server. -
The third number is 3, so the subnet is
192.0.3.0/24, while the server is in192.0.2.0/24. With this addresspingwill printNetwork is unreachableagain.
With prefix /24, the server's neighbours are 192.0.2.2–192.0.2.254. 192.0.2.10/24 is one of them, so ping goes straight to the server.
Key points
-
With
/24, the network number is the first three numbers of the address and the host number is the last. - Neighbours are addresses in one subnet; the kernel will not send a packet into another subnet without a route.
-
A different prefix draws a different boundary:
/25splits a/24subnet in half.