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. 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. For /31 and /32 the formula gives 0, so the tool shows 0 usable hosts, even though /31 is used on some point-to-point links and /32 identifies a single host.

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.
  • Reading 0 usable hosts for /31 as an error: the tool applies the standard minus-two rule, so check whether your equipment allows /31 point-to-point links.

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.

Comments (1)

  • Editorial team

    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, which is why it shows up on router-to-router links. 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?

Popular calculators

All Calculators