NetCalcLab

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.

Accepts /24, a bare 24, a dotted subnet mask such as 255.255.255.0, or a wildcard mask such as 0.0.0.255.

Examples:

Complete CIDR reference table

Every valid IPv4 prefix from /0 to /32 with its mask, wildcard and address counts.

CIDR to subnet mask reference table
PrefixSubnet maskWildcardTotal addressesUsable hostsBlock size
/00.0.0.0255.255.255.2554,294,967,2964,294,967,2944,294,967,296
/1128.0.0.0127.255.255.2552,147,483,6482,147,483,6462,147,483,648
/2192.0.0.063.255.255.2551,073,741,8241,073,741,8221,073,741,824
/3224.0.0.031.255.255.255536,870,912536,870,910536,870,912
/4240.0.0.015.255.255.255268,435,456268,435,454268,435,456
/5248.0.0.07.255.255.255134,217,728134,217,726134,217,728
/6252.0.0.03.255.255.25567,108,86467,108,86267,108,864
/7254.0.0.01.255.255.25533,554,43233,554,43033,554,432
/8255.0.0.00.255.255.25516,777,21616,777,21416,777,216
/9255.128.0.00.127.255.2558,388,6088,388,6068,388,608
/10255.192.0.00.63.255.2554,194,3044,194,3024,194,304
/11255.224.0.00.31.255.2552,097,1522,097,1502,097,152
/12255.240.0.00.15.255.2551,048,5761,048,5741,048,576
/13255.248.0.00.7.255.255524,288524,286524,288
/14255.252.0.00.3.255.255262,144262,142262,144
/15255.254.0.00.1.255.255131,072131,070131,072
/16255.255.0.00.0.255.25565,53665,53465,536
/17255.255.128.00.0.127.25532,76832,76632,768
/18255.255.192.00.0.63.25516,38416,38216,384
/19255.255.224.00.0.31.2558,1928,1908,192
/20255.255.240.00.0.15.2554,0964,0944,096
/21255.255.248.00.0.7.2552,0482,0462,048
/22255.255.252.00.0.3.2551,0241,0221,024
/23255.255.254.00.0.1.255512510512
/24255.255.255.00.0.0.255256254256
/25255.255.255.1280.0.0.127128126128
/26255.255.255.1920.0.0.63646264
/27255.255.255.2240.0.0.31323032
/28255.255.255.2400.0.0.15161416
/29255.255.255.2480.0.0.7868
/30255.255.255.2520.0.0.3424
/31255.255.255.2540.0.0.122 (RFC 3021)2
/32255.255.255.2550.0.0.0111

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 to CIDR prefix lookup
Subnet maskPrefixWildcardUsable hostsBlock size
255.255.255.128/250.0.0.128126128
255.255.255.192/260.0.0.646264
255.255.255.224/270.0.0.323032
255.255.255.240/280.0.0.161416
255.255.255.248/290.0.0.868
255.255.255.252/300.0.0.424
255.255.255.254/310.0.0.202
255.255.255.255/320.0.0.101

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.

Prefix, mask and count
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.

Subnet mask and wildcard mask compared
PrefixSubnet maskWildcard maskMeaning
/24255.255.255.00.0.0.255Match the first three octets; ignore the last
/25255.255.255.1280.0.0.127Match the first 25 bits; ignore the remaining 7
/26255.255.255.1920.0.0.63Match the first 26 bits; ignore the remaining 6
/27255.255.255.2240.0.0.31Match the first 27 bits; ignore the remaining 5
/30255.255.255.2520.0.0.3Match the first 30 bits; ignore the remaining 2
/32255.255.255.2550.0.0.0Match 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.

Host requirement to prefix length
Hosts neededAddresses requiredPrefixAddresses providedSpare
13/2985 usable spare
57/2981 usable spare
1012/28162 usable spare
2527/27323 usable spare
5052/266410 usable spare
100102/2512826 usable spare
200202/2425654 usable spare
500502/2351210 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.