CIDR to Subnet Mask Calculator

Enter the CIDR prefix length to get its subnet mask.

Result

255.255.255.192
0.0.0.63
62 usable hosts

How it is calculated

A CIDR prefix /n means the first n bits of a 32-bit IPv4 address are the network part. The mask is therefore n ones followed by 32 − n zeros, written as four decimal bytes. The wildcard mask is the bitwise inverse of that mask. The number of usable hosts is 232 − n − 2: the all-zeros host address is the network address and the all-ones one is the broadcast address, so both are excluded. Two prefixes are exceptions: a /31 has 2 usable addresses, because RFC 3021 lets a point-to-point link use both of its addresses with no network or broadcast address, and a /32 is a single host, 1. The prefix must be a whole number from 0 to 32; a decimal such as 24.9 is truncated to 24, and a value outside 0–32 gives no result.

Worked example

Take a /26 prefix. The first 26 bits are ones, so the first three bytes are 255 each, and the last byte holds 2 ones and 6 zeros: 11000000 = 128 + 64 = 192. Mask: 255.255.255.192. The wildcard is the inverse, 0.0.0.63. Host bits: 32 − 26 = 6, so 26 = 64 addresses, minus network and broadcast leaves 62 usable hosts. A /26 therefore splits one /24 into four blocks of 64 addresses.

Try this example →

Common mistakes

  • Counting all 232 − n addresses as hosts: two of them, the network and broadcast addresses, cannot be assigned to devices.
  • Confusing the subnet mask with the wildcard mask: ACL syntax on some routers expects the wildcard (0.0.0.63), not 255.255.255.192.
  • Entering the mask itself (255.255.255.0) instead of the prefix length (24); the field takes the number after the slash.
  • Expecting a bigger prefix to mean a bigger network: /28 is smaller than /24 because fewer bits are left for hosts.
  • Using a /31 for an ordinary LAN: its 2 usable addresses follow RFC 3021, which is for point-to-point links only, and the equipment at both ends has to support it.

Sources

About this calculator

CIDR notation (Classless Inter-Domain Routing) expresses a subnet mask as a slash followed by the number of leading 1-bits — /24 means the first 24 bits of the 32-bit address are the network portion. This converts a prefix length directly into the dotted-decimal subnet mask everyone actually configures on routers and servers (/24 = 255.255.255.0), plus the wildcard mask (its bitwise inverse, used in Cisco ACLs) and the count of usable host addresses.

CIDR replaced the old rigid Class A/B/C system in the 1990s to make IP address allocation far more efficient, and converting between prefix length and subnet mask is a daily task for network administrators configuring VLANs, firewalls, and routing tables, and a core topic in every networking certification syllabus.

Was this helpful?

You can pick up to 3 reactions.

Note from the editors

Use the host count to size a subnet before you carve it up. A /22 gives mask 255.255.252.0 and 1,022 usable hosts, while a /30 leaves exactly 2; a /31 also gives 2 on a point-to-point link under RFC 3021, without network or broadcast addresses. The usable figure only subtracts the network and broadcast addresses, so some cloud platforms that reserve more addresses per subnet will give you fewer. Which provider or vendor rules would you like us to mention next?

Comments

  • Be the first to comment.

Popular calculators

All Calculators