A subnet mask and a CIDR prefix are two notations for the same number: how many bits of an IP address are network versus host. Convert between them and the host count follows automatically.
Subnet mask, CIDR prefix, and host count are the same fact
A subnet mask like 255.255.255.0 and a CIDR prefix like /24 describe the identical split between network bits and host bits - they are just two ways of writing it down. The mask spells out, in dotted-decimal form, which bits are fixed (the 1s) and which are available for host addresses (the 0s). The CIDR prefix just counts the 1s. /24 means the first 24 bits are network bits, which is exactly what 255.255.255.0 encodes in binary: three full octets of 1s followed by one octet of 0s.
This matters because most configuration interfaces accept one notation but not the other. Older router firmware and some VPN clients still ask for a dotted-decimal mask; almost everything written in the last fifteen years - cloud VPC consoles, Kubernetes CIDR blocks, firewall rules - expects CIDR. Knowing the conversion means never being stuck when a form wants the notation you don't have on hand.
A valid subnet mask is always a run of contiguous 1 bits followed by a run of contiguous 0 bits, with no gaps - RFC 950 introduced subnet masks, and CIDR (RFC 1519/4632) made the contiguous form mandatory, while RFC 1878 tabulates the resulting host counts for every prefix length from /1 to /32. A dotted-decimal value that does not reduce to that binary pattern (like 255.255.0.255) is not a valid subnet mask, even though it is a valid set of four octets.
- Every octet in a valid mask is one of exactly nine values: 0, 128, 192, 224, 240, 248, 252, 254, 255
- CIDR prefix = count of 1 bits in the mask, read left to right
- Host bits = 32 − CIDR prefix; total addresses in the block = 2^(host bits)
- Usable host addresses = total addresses − 2, for the network and broadcast addresses (RFC 950) - except /31 (point-to-point links, RFC 3021) and /32 (single host), which have no broadcast address to reserve
Mask, prefix, and usable hosts at a glance
The wildcard mask is the bitwise inverse of the subnet mask - Cisco ACLs and some older routing configuration ask for it instead of the mask itself. It is easy to compute by hand: subtract each octet of the subnet mask from 255. 255.255.255.0 inverts to 0.0.0.255.
The full /1 through /32 breakdown, including every intermediate prefix, is available in the calculator above (enter any address with a CIDR suffix, or an address plus a dotted-decimal mask, and the quick-reference table below the results fills in the rest).
| CIDR | Subnet mask | Wildcard mask | Usable hosts |
|---|---|---|---|
| /24 | 255.255.255.0 | 0.0.0.255 | 254 |
| /25 | 255.255.255.128 | 0.0.0.127 | 126 |
| /26 | 255.255.255.192 | 0.0.0.63 | 62 |
| /27 | 255.255.255.224 | 0.0.0.31 | 30 |
| /28 | 255.255.255.240 | 0.0.0.15 | 14 |
| /29 | 255.255.255.248 | 0.0.0.7 | 6 |
| /30 | 255.255.255.252 | 0.0.0.3 | 2 |
| /31 | 255.255.255.254 | 0.0.0.1 | 2 (RFC 3021, no broadcast) |
Reading the calculator output
Entering an address in either notation - 192.168.1.0/24 or 192.168.1.0 with mask 255.255.255.0 - produces the same result set: network address, broadcast address, first and last usable host, total addresses, usable host count, the subnet mask itself, its wildcard-mask inverse, and the CIDR prefix. A binary breakdown shows the address, network address, broadcast address, and mask all aligned by bit position, which is the fastest way to see exactly where the network/host boundary falls.
The tool also reports the address class (A, B, or C, following the historical classful ranges) and whether the network address falls inside a private range - 10.0.0.0/8, 172.16.0.0/12, or 192.168.0.0/16, per RFC 1918. Class is a legacy classification; CIDR replaced classful addressing in 1993 (RFC 1519, later refined by RFC 4632 in 2006), so a /24 carved out of a Class A range is entirely normal and not a misconfiguration - the tool reports the historical class purely as a reference label.
For a /31, the calculator applies RFC 3021: both addresses in the block are usable host addresses, with no network or broadcast address reserved, because a two-address subnet exists only to number the two ends of a point-to-point link. A /32 is a route to a single host, not a subnet with a range at all.
Converting a mask to CIDR by hand
Write the mask in binary, one octet at a time, and count the 1 bits. 255.255.255.192 becomes 11111111.11111111.11111111.11000000 - 26 ones - so the CIDR prefix is /26. The reverse works the same way: /26 means 26 ones followed by 6 zeros, which regrouped into octets is 11111111.11111111.11111111.11000000, or 255.255.255.192.
A shortcut for the last non-zero octet: subtract the octet's value from 256 to get the size of each subnet block in that position. 192 → 256 − 192 = 64, so /26 subnets fall on boundaries of 64 (0, 64, 128, 192). This is the same arithmetic the calculator's subnet-splitting feature uses to lay out contiguous blocks without gaps or overlap.
FAQ
What is the difference between a subnet mask and a CIDR prefix?
None, functionally - they encode the identical network/host bit split. 255.255.255.0 and /24 are the same subnet written two ways. CIDR (RFC 4632) is the more compact and more common notation today; the dotted-decimal mask survives mainly in older firmware and configuration formats that predate it.
How many usable hosts does a /24 have?
254. A /24 has 8 host bits, giving 256 total addresses (2^8), minus 2 for the network address and the broadcast address (RFC 950). The two reserved addresses are why the usable count is always 2 less than the total for any prefix from /1 to /30.
Why is 255.255.0.255 not a valid subnet mask?
A valid mask must be a contiguous run of 1 bits followed by a contiguous run of 0 bits - a requirement CIDR (RFC 1519/4632) made mandatory. 255.255.0.255 in binary is 11111111.11111111.00000000.11111111 - the 1s and 0s are not contiguous, so it cannot express a single network/host boundary. Every valid mask octet is one of nine values: 0, 128, 192, 224, 240, 248, 252, 254, or 255.
What is a wildcard mask and how does it relate to the subnet mask?
A wildcard mask is the bitwise inverse of the subnet mask, used by Cisco access control lists and some routing protocol configurations instead of the mask itself. To compute it, subtract each octet of the subnet mask from 255: the wildcard mask for 255.255.255.0 is 0.0.0.255.
Why does a /31 subnet have 2 usable hosts instead of 0?
A /31 has only 2 addresses total, which under the standard network/broadcast reservation rule would leave 0 usable - useless for numbering a link. RFC 3021 creates an explicit exception for /31: point-to-point links use both addresses as host addresses, with no network or broadcast address reserved, since a two-node link has no need for a broadcast address.
Does the subnet mask affect which IP addresses are private?
No - privacy (RFC 1918) is a property of the address range itself (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16), independent of what mask is applied on top. A /24 carved out of 192.168.0.0/16 is still private; the mask only determines where that particular subnet's boundaries fall within the private range.
Related tools
- Look up ownership and network details for a specific IP address before subnetting around it
- Check the DNS records for a domain hosted inside a subnet you have just calculated
- Find the hostname associated with an IP address inside a given subnet
- Identify which organization or ISP was allocated a given IP block or ASN