CIDR Calculator
Convert a CIDR prefix to a subnet mask or wildcard mask and back again. Enter /24, 255.255.255.0 or 0.0.0.255 and get the mask, wildcard, block size, address counts and binary form, plus a full /0 to /32 reference table.
Complete CIDR reference table
Every valid IPv4 prefix from /0 to /32 with its mask, wildcard and address counts.
| Prefix | Subnet mask | Wildcard | Total addresses | Usable hosts | Block size |
|---|---|---|---|---|---|
| /0 | 0.0.0.0 | 255.255.255.255 | 4,294,967,296 | 4,294,967,294 | 4,294,967,296 |
| /1 | 128.0.0.0 | 127.255.255.255 | 2,147,483,648 | 2,147,483,646 | 2,147,483,648 |
| /2 | 192.0.0.0 | 63.255.255.255 | 1,073,741,824 | 1,073,741,822 | 1,073,741,824 |
| /3 | 224.0.0.0 | 31.255.255.255 | 536,870,912 | 536,870,910 | 536,870,912 |
| /4 | 240.0.0.0 | 15.255.255.255 | 268,435,456 | 268,435,454 | 268,435,456 |
| /5 | 248.0.0.0 | 7.255.255.255 | 134,217,728 | 134,217,726 | 134,217,728 |
| /6 | 252.0.0.0 | 3.255.255.255 | 67,108,864 | 67,108,862 | 67,108,864 |
| /7 | 254.0.0.0 | 1.255.255.255 | 33,554,432 | 33,554,430 | 33,554,432 |
| /8 | 255.0.0.0 | 0.255.255.255 | 16,777,216 | 16,777,214 | 16,777,216 |
| /9 | 255.128.0.0 | 0.127.255.255 | 8,388,608 | 8,388,606 | 8,388,608 |
| /10 | 255.192.0.0 | 0.63.255.255 | 4,194,304 | 4,194,302 | 4,194,304 |
| /11 | 255.224.0.0 | 0.31.255.255 | 2,097,152 | 2,097,150 | 2,097,152 |
| /12 | 255.240.0.0 | 0.15.255.255 | 1,048,576 | 1,048,574 | 1,048,576 |
| /13 | 255.248.0.0 | 0.7.255.255 | 524,288 | 524,286 | 524,288 |
| /14 | 255.252.0.0 | 0.3.255.255 | 262,144 | 262,142 | 262,144 |
| /15 | 255.254.0.0 | 0.1.255.255 | 131,072 | 131,070 | 131,072 |
| /16 | 255.255.0.0 | 0.0.255.255 | 65,536 | 65,534 | 65,536 |
| /17 | 255.255.128.0 | 0.0.127.255 | 32,768 | 32,766 | 32,768 |
| /18 | 255.255.192.0 | 0.0.63.255 | 16,384 | 16,382 | 16,384 |
| /19 | 255.255.224.0 | 0.0.31.255 | 8,192 | 8,190 | 8,192 |
| /20 | 255.255.240.0 | 0.0.15.255 | 4,096 | 4,094 | 4,096 |
| /21 | 255.255.248.0 | 0.0.7.255 | 2,048 | 2,046 | 2,048 |
| /22 | 255.255.252.0 | 0.0.3.255 | 1,024 | 1,022 | 1,024 |
| /23 | 255.255.254.0 | 0.0.1.255 | 512 | 510 | 512 |
| /24 | 255.255.255.0 | 0.0.0.255 | 256 | 254 | 256 |
| /25 | 255.255.255.128 | 0.0.0.127 | 128 | 126 | 128 |
| /26 | 255.255.255.192 | 0.0.0.63 | 64 | 62 | 64 |
| /27 | 255.255.255.224 | 0.0.0.31 | 32 | 30 | 32 |
| /28 | 255.255.255.240 | 0.0.0.15 | 16 | 14 | 16 |
| /29 | 255.255.255.248 | 0.0.0.7 | 8 | 6 | 8 |
| /30 | 255.255.255.252 | 0.0.0.3 | 4 | 2 | 4 |
| /31 | 255.255.255.254 | 0.0.0.1 | 2 | 2 (RFC 3021) | 2 |
| /32 | 255.255.255.255 | 0.0.0.0 | 1 | 1 | 1 |
Quick reference: mask to prefix
Reading a mask written in dotted-decimal form. Count the 1 bits, or use the octet boundaries below.
| Subnet mask | Prefix | Wildcard | Usable hosts | Block size |
|---|---|---|---|---|
| 255.255.255.128 | /25 | 0.0.0.128 | 126 | 128 |
| 255.255.255.192 | /26 | 0.0.0.64 | 62 | 64 |
| 255.255.255.224 | /27 | 0.0.0.32 | 30 | 32 |
| 255.255.255.240 | /28 | 0.0.0.16 | 14 | 16 |
| 255.255.255.248 | /29 | 0.0.0.8 | 6 | 8 |
| 255.255.255.252 | /30 | 0.0.0.4 | 2 | 4 |
| 255.255.255.254 | /31 | 0.0.0.2 | 0 | 2 |
| 255.255.255.255 | /32 | 0.0.0.1 | 0 | 1 |
Example: 255.255.255.224 has three 1 bits in its last octet, so the prefix is 24 + 3 = /27, the wildcard is 0.0.0.31 and there are 32 addresses of which 30 are usable.
What CIDR is and why it replaced classes
Before 1993, IPv4 addresses came in three sizes: class A gave you 16 million addresses, class B gave you 65,536 and class C gave you 256. There was no way to ask for 1,000 addresses, so organisations took the next size up and the global routing table filled with entries that were mostly unused space.
CIDR removed the fixed boundaries. A prefix length now says exactly how many of the 32 bits are network bits, and the mask is just a convenient way to write that same number in dotted-decimal. A /22 gives 1,024 addresses — the size that classful addressing could not express.
Total addresses = 2^(32 − prefix) Subnet mask = prefix 1 bits followed by (32 − prefix) 0 bits Wildcard mask = the bitwise inverse of the subnet mask Block size = 2^(32 − prefix) (same as the address count)
Reading a mask in dotted-decimal
Every subnet mask is a run of 1 bits followed by a run of 0 bits, so each octet can only be one of nine values: 0, 128, 192, 224, 240, 248, 252, 254 or 255. Anything else — 255.255.128.224, for instance — is not a valid mask.
Example: converting 255.255.255.0 to a prefix
The first two octets are 255, contributing 16 bits. The third octet, 240, is 11110000 in binary, contributing 4 more. The fourth octet is 0. So the prefix is 16 + 4 = /20.
255.255.240.0 → /20 → wildcard 0.0.15.255 → 4,096 addresses
Beyond /24 the last octet does all the work, which makes the block-size method faster than counting bits once you know the pattern.
Subnet mask versus wildcard mask
Both express the same boundary with opposite conventions, and mixing them up is the single most common Cisco configuration error.
| Prefix | Subnet mask | Wildcard mask | Meaning |
|---|---|---|---|
| /24 | 255.255.255.0 | 0.0.0.255 | Match the first three octets; ignore the last |
| /25 | 255.255.255.128 | 0.0.0.127 | Match the first 25 bits; ignore the remaining 7 |
| /26 | 255.255.255.192 | 0.0.0.63 | Match the first 26 bits; ignore the remaining 6 |
| /27 | 255.255.255.224 | 0.0.0.31 | Match the first 27 bits; ignore the remaining 5 |
| /30 | 255.255.255.252 | 0.0.0.3 | Match the first 30 bits; ignore the remaining 2 |
| /32 | 255.255.255.255 | 0.0.0.0 | Match all 32 bits — a single host |
In Cisco ACL syntax, 192.168.1.0 0.0.0.255 matches the whole /24 because the wildcard has 1s in the host positions. Writing 192.168.1.0 255.255.255.0 instead would match a completely different and unintended set of addresses, because only the bits where the wildcard is 0 must match — and in that case only the first octet must match 0, which matches nothing useful.
In OSPF the same convention appears in network statements: network 10.0.0.0 0.0.0.255 area 0 enables the protocol on that /24.
Prefix sizing cheat sheet
When sizing a subnet, work backwards from the host count. Add two for the network and broadcast address, then pick the smallest power of two that fits.
| Hosts needed | Addresses required | Prefix | Addresses provided | Spare |
|---|---|---|---|---|
| 1 | 3 | /29 | 8 | 5 usable spare |
| 5 | 7 | /29 | 8 | 1 usable spare |
| 10 | 12 | /28 | 16 | 2 usable spare |
| 25 | 27 | /27 | 32 | 3 usable spare |
| 50 | 52 | /26 | 64 | 10 usable spare |
| 100 | 102 | /25 | 128 | 26 usable spare |
| 200 | 202 | /24 | 256 | 54 usable spare |
| 500 | 502 | /23 | 512 | 10 usable spare |
The VLSM planner applies exactly this table across a list of requirements and allocates the results without overlaps.
CIDR reference pages
Each prefix has its own page with a worked example, the mask, the host range and the subnets it contains.
Frequently asked questions
What does CIDR mean?
CIDR stands for Classless Inter-Domain Routing, introduced in RFC 1518 and RFC 1519 in 1993. It replaced the fixed class A, B and C boundaries with a prefix length, so a network can be any size from a /32 single host up to a /0 default route. The notation writes the prefix as a slash followed by the number of network bits, as in 192.168.1.0/24.
How do I convert a subnet mask to a CIDR prefix?
Count the number of consecutive 1 bits in the mask. For 255.255.255.224 the first three octets contribute 24 ones and the last octet contributes three more, giving /27. The mask must be contiguous — a value such as 255.255.0.255 is invalid because there is a zero bit between ones.
How do I convert a CIDR prefix to a wildcard mask?
Complement each bit of the subnet mask. For /24 the mask is 255.255.255.0, so the wildcard is 0.0.0.255. In a Cisco ACL a wildcard bit of 0 means 'must match' and 1 means 'ignore', which is the opposite convention to the subnet mask — the most common configuration mistake in access lists.
How many addresses are in each CIDR prefix?
The address count is 2 raised to the power of (32 − prefix). A /24 has 2^8 = 256 addresses, a /25 has 128, a /26 has 64 and so on. A /0 has 2^32 = 4,294,967,296 addresses, which requires 64-bit arithmetic to represent correctly.
Why is a /31 special?
A /31 contains only two addresses, and the normal rule reserves two of them for the network and broadcast address, leaving nothing. RFC 3021 redefines /31 as a point-to-point link where both addresses are assignable, so a /31 wastes no space at all. Modern router-to-router links commonly use them.
What is block size and why does it matter?
Block size is the number of addresses in the subnet, equal to 2^(32 − prefix). It tells you the spacing between consecutive subnets of the same size: /27 subnets start every 32 addresses, so within a /24 they begin at .0, .32, .64, .96, .128, .160, .192 and .224. Subnets that are not on a block-size boundary overlap and cause routing errors.