Tools
Subnet Calculator: CIDR, Netmask and Usable Host Range
Type an IPv4 address with its prefix, such as 192.168.1.10/24, and this subnet calculator works out the network address, broadcast address, first and last usable host, the subnet mask and the wildcard mask. It also tells you whether the range is private or public and whether a second address sits inside it. The detail that trips people up most when writing firewall rules is that a rule must name the network address, not a host: 192.168.1.10/24 and 192.168.1.0/24 cover the same 256 addresses, but some firewalls reject or silently rewrite the first form.
Work out a subnet
How the calculator works
An IPv4 address is 32 bits. The prefix (the number after the slash) says how many of those bits identify the network; the rest identify hosts. A /24 keeps 24 network bits and leaves 8 host bits, so the subnet holds 28 = 256 addresses. The calculator applies the subnet mask to your address with a bitwise AND to find the network address, then sets every host bit to 1 to find the broadcast address.
In a normal subnet, the network and broadcast addresses cannot be given to a device, so the usable host count is the total minus two. There are two exceptions. A /31 has two addresses and both are usable on a point-to-point link (RFC 3021). A /32 is a single address, which is what you use in a firewall rule or allow list that should match exactly one machine.
The wildcard mask is the subnet mask with every bit flipped. Cisco access control lists and some other firewalls ask for it instead of the subnet mask, so a /24 is written as 0.0.0.255 rather than 255.255.255.0.
Why subnets matter for security
Splitting a network into subnets is how you keep guest Wi-Fi, staff laptops, servers and card terminals apart, so a compromised device on one cannot freely reach the others. The Cyber Essentials firewall control asks you to block unauthenticated inbound connections by default and to document the rules you do allow. Those rules are written as addresses and prefixes, so getting the range right is the difference between a rule that admits one supplier's office and one that admits a whole block of the internet. A common mistake is writing /16 when /24 was meant, which widens the rule from 256 addresses to 65,536.
The private ranges set aside by RFC 1918 are 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16. They are not routed on the public internet, which is why almost every office and home network uses them internally. If the calculator says an address on your internal network is public, check it before you build rules around it.
Subnet mask cheat sheet
| Prefix | Subnet mask | Total addresses | Usable hosts |
|---|---|---|---|
| /8 | 255.0.0.0 | 16,777,216 | 16,777,214 |
| /9 | 255.128.0.0 | 8,388,608 | 8,388,606 |
| /10 | 255.192.0.0 | 4,194,304 | 4,194,302 |
| /11 | 255.224.0.0 | 2,097,152 | 2,097,150 |
| /12 | 255.240.0.0 | 1,048,576 | 1,048,574 |
| /13 | 255.248.0.0 | 524,288 | 524,286 |
| /14 | 255.252.0.0 | 262,144 | 262,142 |
| /15 | 255.254.0.0 | 131,072 | 131,070 |
| /16 | 255.255.0.0 | 65,536 | 65,534 |
| /17 | 255.255.128.0 | 32,768 | 32,766 |
| /18 | 255.255.192.0 | 16,384 | 16,382 |
| /19 | 255.255.224.0 | 8,192 | 8,190 |
| /20 | 255.255.240.0 | 4,096 | 4,094 |
| /21 | 255.255.248.0 | 2,048 | 2,046 |
| /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 |
| /32 | 255.255.255.255 | 1 | 1 |
Usable hosts for /31 and /32 follow the point-to-point and single-host exceptions described above.