CIDR Calculator
Test cases replayed : 4 of 4 match · Methodology · No outside source listed
Choose a prefix length to see the subnet mask, the wildcard mask and how many addresses the block holds.
Result
Subnet mask
Wildcard mask
- Total addresses in the block
- Usable host addresses
Estimate for planning only, not tax, legal, financial or medical advice. This calculator uses the method explained on this page.
This browser did not allow copying. The sentence is in the box below, already selected: copy it with your keyboard or the menu.
How to use this calculator
Fill in the fields in this order; each step takes you to its field.
- Prefix length (the number after the slash, 0 to 32): enter a number from 0 to 32.
- Read the result: Subnet mask; the panel also shows Wildcard mask, Total addresses in the block and Usable host addresses.
How this calculator works
A CIDR prefix /n keeps the first n of the 32 bits of an IPv4 address for the network, so a block holds 2^(32 − n) addresses (RFC 4632, Classless Inter-domain Routing, rfc-editor.org, read 2026-10-27). The subnet mask has n one-bits followed by zeros; the wildcard mask is its bitwise inverse.
Usable hosts = 2^(32 − n) − 2, because the first address names the network and the last is the broadcast address. A /31 on a point-to-point link uses both addresses (RFC 3021), and a /32 is a single host route.
The formula
| Symbol | Meaning |
|---|---|
| Prefix length (the number after the slash, 0 to 32) | |
| Subnet mask | |
round(x, d) | x rounded to d decimal places, or to a whole number without d. |
Worked example
| Prefix length (the number after the slash, 0 to 32) | 24 |
|---|
| Wildcard mask | 0.0.0.255 |
|---|---|
| Total addresses in the block | 256 |
| Usable host addresses | 254 |
Subnet mask 255.255.255.0 (/24)
Each step uses the unrounded value of the step before it; figures on this page are rounded for display.
Frequently asked questions
How many hosts are in a /24?
256 addresses, of which 254 can be given to hosts.
What is the subnet mask for /26?
255.255.255.192, with 64 addresses and 62 usable hosts.
What does /32 mean?
A single address: RFC 4632 calls it a host route.