The subnet mask has 1s for the network part and 0s for the host part. CIDR notation writes the count of 1s: 255.255.255.0 = /24.
| CIDR | Mask | Host bits | Usable hosts |
|---|---|---|---|
| /24 | 255.255.255.0 | 8 | 254 |
| /25 | 255.255.255.128 | 7 | 126 |
| /26 | 255.255.255.192 | 6 | 62 |
| /27 | 255.255.255.224 | 5 | 30 |
| /28 | 255.255.255.240 | 4 | 14 |
| /29 | 255.255.255.248 | 3 | 6 |
| /30 | 255.255.255.252 | 2 | 2 |
Formulas:
- Usable hosts per subnet = 2^h - 2 (h = host bits; subtract the network address and broadcast address).
- Number of subnets = 2^s (s = bits borrowed from the host part).
- Block size = 256 - the interesting octet of the mask.
Reading a mask
A mask of /24 means the first 24 bits are the network identity and the remaining 8 bits identify hosts. Written in decimal that mask is 255.255.255.0 (twenty-four 1s, then eight 0s).
Worked check: /26
/26 → 26 ones → binary mask ends with 11000000 in the last octet → decimal 192 → 255.255.255.192.
- Host bits
h= 32 − 26 = 6 - Addresses in each subnet = 2⁶ = 64
- Usable hosts = 64 − 2 = 62 (subtract network and broadcast)
Block size shortcut
In the "interesting" octet (the first octet that is not 255 or 0 in the mask), block size = 256 − that octet value. For 255.255.255.192, interesting octet = 192, block size = 64. Subnets therefore start at 0, 64, 128, 192 in that octet.
Borrowing bits for subnets
If you start from /24 and need 4 equal subnets, you borrow 2 host bits because 2² = 4. The new prefix is /26. If you need 8 subnets you borrow 3 bits → /27. Always check that the remaining host bits still give enough usable hosts for the largest LAN.
Common mistake: forgetting to subtract 2 for network and broadcast when counting usable hosts. A /30 has 4 addresses but only 2 usable hosts — perfect for a point-to-point router link, useless for a room of PCs.
Tip: memorise the row for /24 to /30 in the table on this page. Most exam and lab designs use those sizes.
Remember
- Prefix length = number of network 1-bits in the mask.
- Usable hosts = 2^h − 2; block size = 256 − interesting octet.
- Borrow host bits to create more subnets; check hosts still fit.