How to Read CIDR Notation and Calculate a Subnet by Hand
A calculator gives you the answer instantly, but knowing the method lets you sanity-check a firewall rule or a cloud network plan in your head. This guide covers the arithmetic with worked examples you can check against the GotInfo subnet calculator.
What the slash number means
An IPv4 address is 32 bits. CIDR notation such as 192.168.10.0/24 says that the first 24 bits are the network part, shared by every address in the block, and the remaining 8 bits are the host part, which varies. The number of addresses in the block is therefore 2 raised to the number of host bits:
addresses = 2(32 − prefix)
So a /24 has 28 = 256 addresses, a /26 has 26 = 64, and a /30 has 22 = 4. In a normal IPv4 subnet the first address is the network address and the last is the broadcast address, so the usable host count is two less.
Prefix, mask and wildcard
The same information can be written as a subnet mask: 32 bits with ones for the network part and zeros for the host part. A wildcard mask, used in some router access lists, is the inverse. This table covers the prefixes you meet most often.
| Prefix | Subnet mask | Wildcard | Addresses | Usable hosts |
|---|---|---|---|---|
| /8 | 255.0.0.0 | 0.255.255.255 | 16,777,216 | 16,777,214 |
| /16 | 255.255.0.0 | 0.0.255.255 | 65,536 | 65,534 |
| /22 | 255.255.252.0 | 0.0.3.255 | 1,024 | 1,022 |
| /23 | 255.255.254.0 | 0.0.1.255 | 512 | 510 |
| /24 | 255.255.255.0 | 0.0.0.255 | 256 | 254 |
| /25 | 255.255.255.128 | 0.0.0.127 | 128 | 126 |
| /26 | 255.255.255.192 | 0.0.0.63 | 64 | 62 |
| /27 | 255.255.255.224 | 0.0.0.31 | 32 | 30 |
| /28 | 255.255.255.240 | 0.0.0.15 | 16 | 14 |
| /29 | 255.255.255.248 | 0.0.0.7 | 8 | 6 |
| /30 | 255.255.255.252 | 0.0.0.3 | 4 | 2 |
| /31 | 255.255.255.254 | 0.0.0.1 | 2 | 2 (point-to-point links, RFC 3021) |
| /32 | 255.255.255.255 | 0.0.0.0 | 1 | 1 (a single host) |
The mask octets only ever take nine values: 0, 128, 192, 224, 240, 248, 252, 254 and 255. Each one is 256 minus a power of two, which is the key to the shortcut below.
The block-size method
You do not need to convert everything to binary. For any address and prefix:
- Find the interesting octet. This is the octet where the mask is neither 255 nor 0. For a /26 it is the fourth octet (mask 192). For a /22 it is the third (mask 252).
- Work out the block size. Block size = 256 minus the mask value in that octet. For 192 that is 64; for 252 it is 4.
- Find the network address. Round the address's value in the interesting octet down to the nearest multiple of the block size. Octets to the right become 0.
- Find the broadcast address. Add the block size to the network value, subtract 1, and set octets to the right to 255.
- Host range. Network address plus one to broadcast address minus one.
Worked example 1: 192.168.10.77/26
- Mask: 255.255.255.192. Interesting octet: the fourth.
- Block size: 256 − 192 = 64. Blocks start at 0, 64, 128 and 192.
- 77 falls in the block starting at 64, so the network is
192.168.10.64. - Broadcast: 64 + 64 − 1 = 127, so
192.168.10.127. - Usable hosts:
192.168.10.65to192.168.10.126, 62 in total.
Worked example 2: is 10.20.4.1 inside 10.20.0.0/22?
- Mask: 255.255.252.0. Interesting octet: the third. Block size: 256 − 252 = 4.
- The block that starts at 10.20.0.0 covers third-octet values 0, 1, 2 and 3.
- So the range is
10.20.0.0to10.20.3.255, with 1,024 addresses. - 10.20.3.77 is inside. 10.20.4.1 is not: a third octet of 4 starts the next block.
This is the kind of check that matters when a firewall rule or security group "should" allow a host and does not.
Worked example 3: splitting a /24 for four VLANs
You have 192.168.10.0/24 and need four networks of at least 50 hosts each. A /26 gives 62 usable hosts, and a /24 divides into four of them, because each extra prefix bit halves the block:
| Subnet | Hosts | Broadcast |
|---|---|---|
192.168.10.0/26 | .1 to .62 | .63 |
192.168.10.64/26 | .65 to .126 | .127 |
192.168.10.128/26 | .129 to .190 | .191 |
192.168.10.192/26 | .193 to .254 | .255 |
If one VLAN needed 100 hosts, you could use a /25 for it (126 hosts) and split the other half into two /26 networks. Subnets of different sizes in the same block are fine as long as each starts on a multiple of its own block size.
Worked example 4: summarizing routes
Aggregation goes the other way. 198.51.100.0/25, 198.51.100.128/26 and 198.51.100.192/26 together cover every address from .0 to .255, so they collapse into one entry: 198.51.100.0/24. Blocks only combine when they are adjacent, the same size at each step, and the result starts on the right boundary. 203.0.113.0/26 and 203.0.113.64/26 combine into 203.0.113.0/25, but 203.0.113.160/27 sits apart and has to stay as its own entry. The aggregation tool on the subnet calculator does this for a whole list at once.
Common mistakes
- Starting a block on the wrong boundary.
192.168.10.50/26is a host address inside 192.168.10.0/26, not a network. Many tools quietly correct it, but configurations may reject it. - Forgetting the reserved addresses. A /29 has 8 addresses but only 6 hosts, and cloud providers often reserve more. Some reserve several addresses at the start of each subnet for their own routers and DNS.
- Mixing up mask and wildcard. 0.0.0.255 in an access list matches a /24; typed into a subnet mask field, it is invalid.
- Overlapping private ranges. If your office uses 192.168.1.0/24 and so does an employee's home network, VPN routing gets confused. Picking a less common block, such as a /24 somewhere inside 10.0.0.0/8, avoids that.
IPv6 is simpler
The same arithmetic applies to 128-bit addresses, but the conventions remove most of the planning. Each LAN segment is a /64, regardless of how many devices it has, and there is no broadcast address. A site with a /48 has 216 = 65,536 possible /64 networks, and a /56 has 28 = 256. Subnetting usually means numbering the 16 or 8 bits between the site prefix and the /64 boundary, for example giving each building or VLAN its own value in the fourth group. See IPv4 vs IPv6 for how the address halves fit together.
Check your working: open the GotInfo subnet calculator, which shows the network, broadcast, host range and a binary view for any IPv4 or IPv6 CIDR.