Cheat sheet
IPv4 subnet mask cheat sheet, /16 to /32
| Prefix | Subnet mask | Addresses | Usable hosts |
|---|---|---|---|
| /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 |
Reading the results
What each line means
- Network is the first address. It names the subnet and is not given to a device.
- Broadcast is the last address. Packets sent to it reach every host in the subnet.
- Usable range is what you can assign to devices, gateways and DHCP pools.
- Address type tells you if a range is private (RFC 1918), CGNAT, link-local, documentation or public. A public address on an internal asset list is worth a second look.
- Reverse DNS zone is the in-addr.arpa or ip6.arpa zone you'd create for PTR records.
Open source
MIT licensed: use the code in your own tools
The maths behind this page is one dependency-free TypeScript file: IPv4 and IPv6 parsing, RFC 5952 address compression, VLSM planning and range-to-CIDR. It is exactly the code this page runs. Read it, copy it into your scripts or product, and change it as you like under the MIT license.
Link to this calculator from your docs, wiki or runbook:
<a href="https://varaxontech.com/subnet-calculator">Free subnet calculator by Varaxon</a>After the subnet plan
Scanning those subnets?
Once you know your ranges, scan them with the scanner you already use and upload the export. Varaxon Scan Hub ranks every finding by CISA KEV, EPSS and CVSS and turns it into a report your team or client will act on. Not sure if a CVE matters? Try the free CVE checker.
Questions
Subnet calculator FAQ
How do I calculate a subnet from a CIDR?
The prefix (the number after the slash) says how many bits belong to the network. Set those bits to 1 to get the mask, AND it with the address to get the network, and set the remaining host bits to 1 to get the broadcast. The usable hosts sit in between. The calculator does all of it as you type.
How many usable hosts are in a /24?
254. A /24 has 256 addresses, and the first (network) and last (broadcast) can't be given to devices. In general a subnet has 2^(32 - prefix) addresses and 2^(32 - prefix) - 2 usable hosts.
Why does a /31 show two usable hosts?
RFC 3021 lets a /31 be used for point-to-point links, where neither address is needed as network or broadcast. A /32 is a single host, used for loopbacks and host routes.
What is VLSM?
Variable Length Subnet Masking: cutting one network into subnets of different sizes, so a 100-device office and a 2-address router link don't both waste a /25. Enter how many hosts each subnet needs and the calculator places the largest first so every block stays aligned.
What is a wildcard mask?
The inverse of the subnet mask, used by Cisco ACLs and OSPF. For 255.255.255.0 the wildcard is 0.0.0.255.
Does it work for IPv6?
Yes. Enter any IPv6 address with a prefix, such as 2001:db8::/48, to get the network, last address, address count, how many /64 subnets it holds, the address type and the reverse DNS zone.
Is my data sent anywhere?
No. Every calculation runs in your browser. Nothing you type leaves your device, so it is safe to use with internal address plans.
Can I use the code?
Yes. The calculator is open source under the MIT license: copy it, change it and ship it in your own tools, commercial or not. Keep the license notice.
