Calculate a subnet
Enter a network in CIDR form to get its range, mask and host count:
The cheat sheet
| Prefix | Netmask | Addresses | Usable hosts |
|---|---|---|---|
| /8 | 255.0.0.0 | 16,777,216 | 16,777,214 |
| /16 | 255.255.0.0 | 65,536 | 65,534 |
| /20 | 255.255.240.0 | 4,096 | 4,094 |
| /22 | 255.255.252.0 | 1,024 | 1,022 |
| /23 | 255.255.254.0 | 512 | 510 |
| /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 |
| /29 | 255.255.255.248 | 8 | 6 |
| /30 | 255.255.255.252 | 4 | 2 |
| /31 | 255.255.255.254 | 2 | 2 (point-to-point links, RFC 3021) |
| /32 | 255.255.255.255 | 1 | 1 (a single host) |
The formulas
- Addresses in a block = 2(32 − prefix).
- Usable hosts = addresses − 2. The first address is the network address and the last is the broadcast address; neither can be given to a device. (A /31 and a /32 are the exceptions.)
- Block size in the interesting octet = 256 − the mask's value in that octet. A mask of 255.255.255.192 gives 256 − 192 = 64.
Worked example: 192.0.2.130/26
- A /26 mask is 255.255.255.192, so the block size is 64 and blocks start at 0, 64, 128 and 192.
- 130 falls in the block that starts at 128, so the network address is
192.0.2.128. - The block ends before 192, so the broadcast address is
192.0.2.191. - Usable hosts run from
192.0.2.129to192.0.2.190, which is 62 addresses.
Splitting a network
Each extra bit in the prefix halves the block. Splitting 192.0.2.0/24 into four equal parts gives four /26 blocks: 192.0.2.0/26, .64/26, .128/26 and .192/26, each with 62 usable hosts. Pick the smallest block that fits the number of devices with room to grow.
Private ranges
| Range | Size | Common use |
|---|---|---|
10.0.0.0/8 | 16.7 million | Large organisations, cloud networks |
172.16.0.0/12 | 1 million | Mid-size networks, containers |
192.168.0.0/16 | 65,536 | Homes and small offices |
These private ranges (RFC 1918) are never routed on the internet. See how to find your IP address to tell your private and public addresses apart.
And IPv6?
The idea is the same, with 128 bits instead of 32. The standard subnet is a /64, so you don't count hosts one by one. A home usually receives a /56 or /60, which holds 256 or 16 networks. Read IPv6 address format for how the addresses are written.