You've probably seen notation like 192.168.1.0/24 in a network settings screen. What does the /24 actually mean, and how do you turn it into a subnet mask? This article walks through what CIDR notation means, how it relates to a subnet mask, and how to calculate the number of usable hosts with a real worked example.
What CIDR notation means
CIDR (Classless Inter-Domain Routing) is a notation that appends /number to an IP address to indicate how many bits make up the network portion. An IPv4 address is 32 bits long, and CIDR splits those bits into a "network" portion at the front and a "host" portion at the back. /24 means the first 24 bits identify the network, leaving the remaining 8 bits (32-24) to identify individual hosts within it. CIDR replaced the older, rigid class-based system (Class A/B/C), letting networks be sized as flexibly as needed rather than in fixed chunks.
Converting CIDR to a subnet mask
A subnet mask is what you get when you set that many leading bits to 1 (and the rest to 0) across all 32 bits, then write it out in dotted-decimal form, 8 bits at a time. For /24, the first 24 bits are all 1 and the remaining 8 are 0, so in binary that's 11111111.11111111.11111111.00000000, which converts to 255.255.255.0. A few common ones, for reference:
/8→255.0.0.0/16→255.255.0.0/24→255.255.255.0/25→255.255.255.128/30→255.255.255.252
When a prefix isn't a multiple of 8, the last octet ends up being a value like 128, 192, 224, 240, 248, 252, or 254 — the decimal value of however many leading bits are set to 1 within that octet. For example, /25 sets just one bit in the last octet (10000000), which is 128.
Calculating usable host count
How many addresses fit in a network depends on the number of host bits. The total address count is 2^(32-prefix), and out of that block, the very first address is reserved as the network address (identifying the network itself) and the very last is reserved as the broadcast address (used to address everyone on the network at once). So the number of addresses actually assignable to hosts is 2^(32-prefix) - 2. Take /24 as an example: with 8 host bits, the total is 2^8 = 256 addresses, and subtracting the network and broadcast addresses leaves 254 usable addresses. For 192.168.1.0/24, the network address is 192.168.1.0, the broadcast address is 192.168.1.255, and usable addresses run from 192.168.1.1 through 192.168.1.254. There are exceptions to this rule at the extremes — /31 (used for point-to-point links, where both addresses in the pair are usable) and /32 (identifying a single host) don't follow the network/broadcast split.
A bigger example to double-check the math
For a /16, there are 16 host bits, so the total address count is 2^16 = 65,536, with 65,534 usable — and the subnet mask works out to 255.255.0.0. A single prefix number is enough to derive the network range, the subnet mask, and the usable host count, but doing the binary math by hand every time is tedious and easy to get wrong. Plugging any CIDR block into a calculator that instantly returns the network address, broadcast address, and usable range is a lot faster and more reliable.
Full CIDR reference table (/0 – /32)
A quick reference of the subnet mask, wildcard mask, and address count for every prefix length. Values are computed (verified with node), so you can use them directly when designing subnets or writing firewall rules.
| CIDR | Subnet mask | Wildcard mask | Total addresses | Usable hosts |
|---|---|---|---|---|
| /0 | 0.0.0.0 | 255.255.255.255 | 4,294,967,296 | 4,294,967,294 |
| /1 | 128.0.0.0 | 127.255.255.255 | 2,147,483,648 | 2,147,483,646 |
| /2 | 192.0.0.0 | 63.255.255.255 | 1,073,741,824 | 1,073,741,822 |
| /3 | 224.0.0.0 | 31.255.255.255 | 536,870,912 | 536,870,910 |
| /4 | 240.0.0.0 | 15.255.255.255 | 268,435,456 | 268,435,454 |
| /5 | 248.0.0.0 | 7.255.255.255 | 134,217,728 | 134,217,726 |
| /6 | 252.0.0.0 | 3.255.255.255 | 67,108,864 | 67,108,862 |
| /7 | 254.0.0.0 | 1.255.255.255 | 33,554,432 | 33,554,430 |
| /8 | 255.0.0.0 | 0.255.255.255 | 16,777,216 | 16,777,214 |
| /9 | 255.128.0.0 | 0.127.255.255 | 8,388,608 | 8,388,606 |
| /10 | 255.192.0.0 | 0.63.255.255 | 4,194,304 | 4,194,302 |
| /11 | 255.224.0.0 | 0.31.255.255 | 2,097,152 | 2,097,150 |
| /12 | 255.240.0.0 | 0.15.255.255 | 1,048,576 | 1,048,574 |
| /13 | 255.248.0.0 | 0.7.255.255 | 524,288 | 524,286 |
| /14 | 255.252.0.0 | 0.3.255.255 | 262,144 | 262,142 |
| /15 | 255.254.0.0 | 0.1.255.255 | 131,072 | 131,070 |
| /16 | 255.255.0.0 | 0.0.255.255 | 65,536 | 65,534 |
| /17 | 255.255.128.0 | 0.0.127.255 | 32,768 | 32,766 |
| /18 | 255.255.192.0 | 0.0.63.255 | 16,384 | 16,382 |
| /19 | 255.255.224.0 | 0.0.31.255 | 8,192 | 8,190 |
| /20 | 255.255.240.0 | 0.0.15.255 | 4,096 | 4,094 |
| /21 | 255.255.248.0 | 0.0.7.255 | 2,048 | 2,046 |
| /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 * |
| /32 | 255.255.255.255 | 0.0.0.0 | 1 | 1 * |
* /31 uses both addresses for point-to-point links (RFC 3021). /32 designates a single host. For every other prefix, "usable hosts" excludes the network and broadcast addresses (2 total).
📐 Try it yourself with the tool
CIDR Notation and How to Calculate a Subnet Mask — Convert CIDR notation like /24 into a subnet mask