Skip to content
ENExplore Calculators

Subnet Mask Calculator

Convert a CIDR prefix length into its dotted-decimal subnet mask, wildcard mask and usable host count.

About Subnet Mask Calculator

A prefix length says how many leading bits belong to the network. Setting those bits to 1 and the rest to 0 gives the subnet mask; inverting it gives the wildcard mask used in ACLs. Two addresses in each block are reserved for the network and broadcast addresses, except /31 (point-to-point) and /32 (host route). Every switch, router, firewall and DHCP scope wants the mask in a different notation, and a mask that is one bit off silently blackholes half a subnet.

Formula

Subnet Mask

The mask is the 32-bit value whose leading p bits are 1; usable hosts = 2^(32 − p) − 2.

p
CIDR prefix length in bits
mask
Dotted-decimal subnet mask

Worked example

With the default values below, Subnet Mask Calculator returns Subnet Mask of 255.255.255.0. Change any input above and every figure here is recalculated in your browser.

Inputs used

Prefix length (CIDR)accepts 0–32 bits
24 bits

Results

Subnet Mask
255.255.255.0
Wildcard Mask
0.0.0.255
Addresses in Block
256
Usable Hosts
254

Step by step

  1. 1Values used
  2. 2Subnet Mask
  3. 3Subnet Mask= 255.255.255.0
  4. 4Wildcard Mask= 0.0.0.255
  5. 5Addresses in Block= 256
  6. 6Usable Hosts= 254

Assumptions and limits

  • The result is derived only from the single input listed above. Anything not among them is not part of the calculation.
  • In particular, this calculator does not take inflation, tax, fees or charges or compounding frequency into account.
  • Figures are rounded for display to whole numbers, so totals built from several rounded parts can differ slightly from the unrounded arithmetic.

How these calculators are built and tested is described on the Methodology page. If a figure looks wrong, please report it.

Guides that use this calculator

Frequently Asked Questions

How is Subnet Mask calculated?

The mask is the 32-bit value whose leading p bits are 1; usable hosts = 2^(32 − p) − 2. A prefix length says how many leading bits belong to the network. Setting those bits to 1 and the rest to 0 gives the subnet mask; inverting it gives the wildcard mask used in ACLs. Two addresses in each block are reserved for the network and broadcast addresses, except /31 (point-to-point) and /32 (host route).

Why does Subnet Mask matter?

Every switch, router, firewall and DHCP scope wants the mask in a different notation, and a mask that is one bit off silently blackholes half a subnet.

What values do I need to enter?

This calculator takes 1 input: Prefix length (CIDR). The pre-filled defaults are a realistic starting point — replace them with figures from your own environment for a result you can act on.

Subnet Mask Calculator | Calcrivo