hop 11 of 32 · 5 min
IP addresses and what a mask means
An IPv4 address is 32 bits, written as four bytes: 172.16.5.42. It is not one number. It is two, and the mask says where to cut.
The mask
172.16.5.42/24 means the first 24 bits are the network and the last 8 are the host.
172.16.5.42 10101100 00010000 00000101 00101010
/24 mask 11111111 11111111 11111111 00000000
<------ network ---------> <-host->
network address 172.16.5.0
broadcast 172.16.5.255
usable hosts 172.16.5.1 to 172.16.5.254 (254 of them)Two addresses are never assignable: all host bits zero is the network itself, all host bits one is the broadcast. That is where the minus two comes from.
| Prefix | Host bits | Addresses | Usable |
|---|---|---|---|
| /24 | 8 | 256 | 254 |
| /25 | 7 | 128 | 126 |
| /26 | 6 | 64 | 62 |
| /27 | 5 | 32 | 30 |
| /30 | 2 | 4 | 2 |
Private ranges
Three blocks are reserved for internal use and never routed on the public internet:
10.0.0.0/8172.16.0.0/12192.168.0.0/16
Your home router hands out addresses from one of these and translates them to its single public address on the way out. That is NAT, and it is why IPv4 has lasted long past the point it should have run out.