RunTheTests
/

Subnet Mask to CIDR

Convert between prefix length and subnet mask, with host counts.

What you provide

Result

/24 = 255.255.255.0 — 254 usable hosts

Usable hosts are two fewer than the total, because the first address is the network and the last is the broadcast.

Mask and wildcard, split at /24

Subnet mask

11111111111111111111111100000000

255.255.255.0 — 1s mark the network

Wildcard mask

00000000000000000000000011111111

0.0.0.255 — the exact inverse, which is what ACLs and OSPF take

  • Network — 24 bits
  • Host — 8 bits
Diagnostic telemetry
Prefix length
/24
Subnet mask
255.255.255.0
Wildcard mask
0.0.0.255
Total addresses
256
Usable hosts
254

What this cannot tell you

  • Pure arithmetic on the definition of a subnet mask. There is nothing here that can drift or need updating.
  • IPv4 only.

Take this with you

How this calculation works

A subnet mask is simply a run of ones followed by a run of zeros: the prefix length says how many ones. This tool converts either form to the other and counts the hosts, using the definition directly rather than a lookup table, so any prefix from /0 to /32 works.

What the results mean

Wildcard mask
The inverse of the subnet mask, used by Cisco access lists and some routing configurations.
Usable hosts
Two fewer than the total for /30 and larger, because the network and broadcast addresses are reserved. A /31 and /32 are the exceptions.

Frequently asked questions

Why does a /24 give 254 hosts, not 256?

The first address identifies the network and the last is the broadcast, and neither can be assigned to a device. So 256 total addresses leave 254 usable.

Is 255.255.255.0 the same as /24?

Yes. That mask is 24 ones followed by 8 zeros, which is exactly what /24 means. Enter either form above to see the other.

Put this on your own site

Free to embed, no attribution required beyond the source link the frame carries itself. It runs entirely in your visitor's browser, sets no cookies and loads no third-party script.

Embed code
<iframe src="https://runthetests.com/embed/subnet-mask-cidr/" width="100%" height="560" style="border:1px solid #e5e5e5;border-radius:8px" title="Subnet Mask to CIDR" loading="lazy"></iframe>

Preview it at https://runthetests.com/embed/subnet-mask-cidr/. Embedded pages are marked noindex, so yours stays the canonical copy — not this one.

More in NetMath