Subnetting scares most networking students, but it becomes easy once you know a few patterns.
Analogy: an IP network is like a street. The network part of the address is the street name and the host part is the house number. Subnetting divides one long street into several shorter streets, each with its own range of house numbers.
Key terms
- Network address: the first address in a subnet. It names the subnet and can't be given to a device.
- Broadcast address: the last address. It reaches every device in the subnet and can't be given to a device.
- Usable hosts: every address in between.
- Prefix (CIDR): the /number, showing how many bits belong to the network.
Cheat sheet
| Prefix | Subnet mask | Total addresses | Usable hosts | Block size |
|---|---|---|---|---|
| /24 | 255.255.255.0 | 256 | 254 | 256 |
| /25 | 255.255.255.128 | 128 | 126 | 128 |
| /26 | 255.255.255.192 | 64 | 62 | 64 |
| /27 | 255.255.255.224 | 32 | 30 | 32 |
| /28 | 255.255.255.240 | 16 | 14 | 16 |
| /29 | 255.255.255.248 | 8 | 6 | 8 |
| /30 | 255.255.255.252 | 4 | 2 | 4 |
Formulas: total addresses = 2(32 − prefix), and usable hosts = total − 2.
The block size trick
Block size = 256 − the last number in the mask that isn't 255. For /26 (255.255.255.192) the block size is 256 − 192 = 64, so subnets start every 64 addresses: .0, .64, .128 and .192.
Worked example
Split 192.168.10.0/24 into four /26 subnets:
| Subnet | Network | First usable | Last usable | Broadcast |
|---|---|---|---|---|
| 1 | 192.168.10.0 | 192.168.10.1 | 192.168.10.62 | 192.168.10.63 |
| 2 | 192.168.10.64 | 192.168.10.65 | 192.168.10.126 | 192.168.10.127 |
| 3 | 192.168.10.128 | 192.168.10.129 | 192.168.10.190 | 192.168.10.191 |
| 4 | 192.168.10.192 | 192.168.10.193 | 192.168.10.254 | 192.168.10.255 |
Choosing the right size
Pick the smallest subnet that fits your hosts, with some room to grow:
- A link between two routers: /30 (2 hosts)
- A small office of 20 devices: /27 (30 hosts)
- An office of 50 devices: /26 (62 hosts)
- An office of 200 devices: /24 (254 hosts)
Private address ranges
These ranges are reserved for internal networks and are not routed on the internet: 10.0.0.0/8, 172.16.0.0/12 (172.16.x.x to 172.31.x.x) and 192.168.0.0/16.
Practice questions
Try each one first, then click to see the answer.
1. How many usable hosts are in a /28?
14. A /28 has 16 addresses; subtract the network and broadcast addresses.
2. What is the subnet mask for /27?
255.255.255.224
3. Which subnet does 192.168.1.75/26 belong to?
192.168.1.64/26. With a block size of 64, subnets start at .0, .64, .128 and .192, and .75 falls between .64 and .127.
4. What is the broadcast address of 10.0.0.32/28?
10.0.0.47. The block size is 16, so the subnet runs from .32 to .47.
5. You need a subnet for 45 hosts. Which prefix?
/26, which gives 62 usable hosts. A /27 only gives 30.
6. Is 172.16.5.63 a valid host address in 172.16.5.0/26?
No. It is the broadcast address of that subnet.