Networking · 5 min read
Subnetting basics
A subnet is a slice of an IP network. Subnetting lets you split one big network into smaller ones, so devices are grouped and traffic stays where it belongs.
Network part vs host part
An IPv4 address is 32 bits. The subnet mask says how many of those bits identify the network. The rest identify individual hosts.
CIDR notation writes the mask as a number of bits. 192.168.1.0/24 means the first 24 bits are the network, which is the same as the mask 255.255.255.0.
Cheat sheet
| CIDR | Mask | Addresses | Usable hosts |
|---|---|---|---|
| /24 | 255.255.255.0 | 256 | 254 |
| /25 | 255.255.255.128 | 128 | 126 |
| /26 | 255.255.255.192 | 64 | 62 |
| /27 | 255.255.255.224 | 32 | 30 |
| /28 | 255.255.255.240 | 16 | 14 |
| /30 | 255.255.255.252 | 4 | 2 |
Formula: usable hosts = 2^(32 − prefix) − 2. You subtract 2 because the first address is the network address and the last is the broadcast address.
The block-size trick
Take the interesting octet of the mask (the one that isn't 255 or 0) and subtract it from 256. That's the block size, and subnets start at every multiple of it.
Worked example: 192.168.10.0/26
| Subnet | Network | Usable range | Broadcast |
|---|---|---|---|
| 1 | .0 | .1 – .62 | .63 |
| 2 | .64 | .65 – .126 | .127 |
| 3 | .128 | .129 – .190 | .191 |
| 4 | .192 | .193 – .254 | .255 |
Practice
Which subnet does 10.0.5.77/27 belong to? Hint: the block size is 32.
Show answer
Network 10.0.5.64, usable .65 – .94, broadcast .95.