opyebCidrPlan

CIDR notation and subnet masks from the ground up

Basics · 6 min read

In one line: What 192.0.2.0/24 actually means: network and broadcast addresses, usable host counts, subnet masks and wildcard masks in one place.

192.0.2.0/24 is two things: an address and a number after the slash. The number says how many leading bits identify the network — 24 here — so the remaining 8 bits belong to hosts and the block contains 2⁸ = 256 addresses.

What the prefix decides

IPv4 has 32 bits and IPv6 has 128. A prefix length p leaves 32 − p or 128 − p host bits, and the total number of addresses is two to that power. A longer prefix means a smaller block: /24 is one 256th of a /16.

CIDRTotalUsableSubnet mask
/24256254255.255.255.0
/25128126255.255.255.128
/266462255.255.255.192
/273230255.255.255.224
/281614255.255.255.240
/2986255.255.255.248
/3042255.255.255.252
/3122255.255.255.254
/3211255.255.255.255

Usable is 2ⁿ−2 because the lowest address (the network) and the highest (the broadcast) cannot belong to a host. The exceptions are /31, where RFC 3021 lets point-to-point links use both addresses, and /32, a single address naming one host.

Mask and wildcard

A subnet mask sets network bits to 1 and host bits to 0. The wildcard mask is its complement and is what access control lists and OSPF configurations expect. Added together they always make 255.255.255.255.

/26  mask       255.255.255.192   11111111.11111111.11111111.11000000
     wildcard   0.0.0.63          00000000.00000000.00000000.00111111
     network    192.0.2.0         (all six host bits cleared)
     broadcast  192.0.2.63        (all six host bits set)
     usable     192.0.2.1 – 192.0.2.62 (62 addresses)

Common mistakes

  • Treating a host address as the network. 10.0.0.37/24 is normalised to 10.0.0.0/24. Check the prefix when you write a firewall rule.
  • Reusing private space blindly. RFC 1918 gives 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16, and every organisation can use them. Any future connection needs a range check first.
  • Putting real addresses in documents. Documentation should use RFC 5737 blocks — 192.0.2.0/24, 198.51.100.0/24, 203.0.113.0/24 — which never collide with a real service.
  • Assuming only /30 is point-to-point. Modern equipment also accepts /31 on point-to-point links and saves two addresses.

Where the numbers come from

All of this is bit arithmetic. The network address is the address AND the mask; the broadcast is the address OR the inverted mask. IPv6 is 128 bits, which is hard to do by hand and wrong with JavaScript's 32-bit bitwise operators. CidrPlan stores every address as a BigInt, so a block such as 2001:db8::/32 is exact to the last bit.

Everything is calculated in your browser. The ranges you type are not stored on a server.

Back to the CIDR calculator

Frequently asked questions

Why can a /24 only use 254 addresses?

The lowest address is the network and the highest is the broadcast, so two of the 256 addresses are reserved.

How do a subnet mask and a wildcard mask differ?

The mask sets network bits to 1; the wildcard sets them to 0. They are bitwise inverses, and ACLs and OSPF use the wildcard form.

What happens if I type a host address with a prefix?

It is normalised to its network. 10.0.0.37/24 describes the same block as 10.0.0.0/24.

Sources

Read next