Guide
CIDR vs subnet mask in IPv4
Learn how a CIDR prefix converts to an IPv4 subnet mask, what each bit means, and when the two notations are equivalent.
by Tools in a Tab · Published on · Reviewed on
Short answer
CIDR and a subnet mask can describe the same IPv4 network boundary in two
different notations. /24 counts 24 network bits;
255.255.255.0 displays those 24 ones followed by 8 zeros.
Common equivalents
| CIDR | Subnet mask | Total addresses |
|---|---|---|
/8 |
255.0.0.0 |
16,777,216 |
/16 |
255.255.0.0 |
65,536 |
/24 |
255.255.255.0 |
256 |
/27 |
255.255.255.224 |
32 |
/32 |
255.255.255.255 |
1 |
To convert a prefix, write the stated number of 1 bits and fill the 32-bit
value with 0. Split it into four octets and convert each group to decimal.
/27
11111111.11111111.11111111.11100000
255.255.255.224
The IPv4 subnet calculator accepts /27,
27, or the dotted-decimal mask and also displays the wildcard.
Why the mask must be contiguous
A valid CIDR subnet mask has one uninterrupted sequence of ones on the left and
zeros on the right. 255.255.255.224 is valid; 255.0.255.0 is not a CIDR
prefix because ones appear again after the zeros begin.
CIDR expresses prefixes and route aggregation without relying on the old class A, B, and C boundaries. RFC 4632 describes classless addressing and aggregation.
A mask is not a network address
The mask only identifies which bits form the prefix. You still need an IP to calculate a particular network:
IP: 192.168.1.42
prefix: /27
network: 192.168.1.32
Two devices can use the same mask while belonging to different networks. The
equivalence between /27 and 255.255.255.224 does not identify either
network by itself.