CIRCUITO
CARIOCA TI · DOCUMENTATION
♙
Networking converter

CIDR Converter

Convert IPv4 CIDR prefixes to subnet masks and wildcard masks, validate dotted-decimal masks and calculate address, host and subnet sizing.

CIDRIPv4Subnet MaskWildcard MaskPrefix LengthRFC 3021

CIDR, subnet mask and wildcard converter

Convert a prefix length to dotted-decimal mask and wildcard, or validate a contiguous IPv4 subnet mask and recover its CIDR prefix.

CIDR mode accepts 24 or /24. Mask mode expects values such as 255.255.255.0.
CIDR · RFC 4632

What CIDR notation means

CIDR represents an IPv4 prefix with an address followed by a slash and a prefix length. In IPv4, the length ranges from /0 through /32 and indicates how many of the 32 most-significant address bits belong to the prefix. For example, /24 corresponds to 24 leading one bits in the subnet mask and 8 remaining host bits.

SUBNET MASK

CIDR subnet masks are contiguous

For conventional CIDR prefix notation, a subnet mask is formed by a contiguous sequence of one bits from the most-significant side followed only by zero bits. Thus /24 is 11111111.11111111.11111111.00000000, or 255.255.255.0. A pattern such as 255.0.255.0 is not a valid contiguous CIDR subnet mask.

WILDCARD MASK

Wildcard mask: inverse of the subnet mask in this conversion

For the CIDR-to-wildcard conversion shown here, each subnet-mask bit is inverted: 255.255.255.0 becomes 0.0.0.255. In Cisco-style ACL matching, a wildcard bit of 0 means the corresponding address bit must match, while a wildcard bit of 1 means that bit can be ignored. Unlike subnet masks, ACL wildcard masks can also be intentionally noncontiguous, so not every possible wildcard represents the inverse of a valid CIDR subnet mask.

ADDRESS COUNT

How many IPv4 addresses fit in a prefix?

IPv4 has 32 address bits. A /P prefix therefore leaves 32 − P host bits, producing 2^(32−P) addresses in the block. A /24 has 256 addresses, /25 has 128, /26 has 64, /27 has 32, /28 has 16, /29 has 8 and /30 has 4.

/31 · RFC 3021

/31 is a special and useful point-to-point case

The traditional “total addresses minus network and broadcast” shortcut does not apply to an RFC 3021 /31 point-to-point link. A /31 contains two addresses and, for the limited point-to-point use defined by RFC 3021, both are interpreted as endpoint addresses. The RFC does not generalize this behavior to every type of interface.

/32

/32 identifies a single IPv4 address

A /32 has no host bits and contains exactly one IPv4 address. It is commonly used as a host route, loopback prefix or an exact-address match in routing and policy contexts. It should not be processed with the old “subtract two hosts” rule.

BLOCK SIZE

The 256-minus-mask shortcut

For subnetting by hand, identify the first mask octet that is not 255 and subtract it from 256. For /26, the mask is 255.255.255.192, so the increment is 256 − 192 = 64. Subnet boundaries in that octet occur at 0, 64, 128 and 192. The calculator shows the relevant octet and block increment.

VLSM

CIDR and VLSM are related, but not identical concepts

CIDR provides classless prefix-length notation and aggregation. VLSM — Variable Length Subnet Masking — describes using different prefix lengths inside an addressing plan so subnets can be sized according to need. Both rely on classless prefix handling, but one term should not simply be used as a synonym for the other.

CLASSLESS NETWORKING

CIDR replaced fixed class boundaries

Modern IPv4 routing is classless: the prefix length explicitly defines the significant network bits. Historical Class A, B and C terminology can still appear in training material, but it is not required to determine a modern CIDR prefix. For example, /20, /23 and /27 are perfectly normal classless prefixes.

ACLs

How wildcard masks are read in ACLs

In Cisco IP ACL wildcard matching, zero means “check this corresponding address bit” and one means “ignore this bit”. Therefore 192.0.2.0 with wildcard 0.0.0.255 matches values where the first 24 bits must agree and the final eight bits are not checked. Wildcard syntax is a matching mechanism, not another way to configure an interface subnet mask.

FAQ

CIDR converter frequently asked questions

What does /24 mean in IPv4?+

It means the first 24 of the 32 IPv4 bits form the prefix. The corresponding contiguous subnet mask is 255.255.255.0, leaving 8 host bits and 256 addresses in the block.

How do I convert CIDR to a subnet mask?+

Write the prefix length as that many leading one bits in a 32-bit mask, followed by zeros, then convert each 8-bit octet to decimal. /26 becomes 255.255.255.192.

How do I convert a subnet mask to CIDR?+

For a valid contiguous CIDR mask, count the leading one bits. 255.255.255.0 contains 24 leading ones, so it is /24.

Is 255.0.255.0 a valid CIDR subnet mask?+

No. A conventional CIDR subnet mask must contain contiguous leading one bits followed only by zero bits.

Is a wildcard always the inverse of a subnet mask?+

The wildcard produced from a CIDR mask is its bitwise inverse. However, ACL wildcard masks can be noncontiguous, so not every possible wildcard is the inverse of a valid CIDR subnet mask.

What does 0 mean in a Cisco wildcard mask?+

A zero bit means the corresponding address bit must be checked and match. A one bit means that corresponding bit is ignored for the wildcard comparison.

How many addresses are in a /24?+

A /24 leaves 8 host bits, so the block contains 2^8 = 256 IPv4 addresses.

How many traditional usable hosts are in a /24?+

In the conventional subnet model, 254 addresses are assignable to hosts because the subnet address and directed-broadcast address are reserved.

Does a /31 have two usable addresses?+

On a point-to-point link operated according to RFC 3021, yes. Both addresses are interpreted as endpoint addresses. RFC 3021 is specifically scoped to point-to-point links.

What is a /32 used for?+

A /32 identifies exactly one IPv4 address. It is commonly used for host routes, loopbacks and exact-address matches.

What is the block-size shortcut?+

In the first subnet-mask octet that is not 255, subtract the mask value from 256. For 255.255.255.192, the increment is 64.

Are CIDR and VLSM the same thing?+

No. They are related classless-addressing concepts. CIDR uses explicit prefix lengths and aggregation; VLSM uses different prefix lengths to size subnets according to need.

Do Class A, B and C determine modern subnet sizes?+

No. Modern CIDR routing is classless and uses an explicit prefix length. Historical class terminology can be educational but is not needed to interpret /20, /24, /27 and other prefixes.

Does this converter calculate the network and broadcast address for a specific IP?+

This page converts prefix lengths and subnet masks. Use the IPv4 calculator when you need the network address, broadcast address and exact host range for a specific IPv4 address/prefix.