Skip to content
Calciyums
DeveloperNovember 10, 20263 min read

How do you calculate an IP subnet?

The prefix length fixes a network's boundaries and how many devices fit.

An IP address and a prefix length (like /24) together fix where a network starts and ends, its first and last usable address, and how many devices it can hold. The bigger the prefix, the smaller the network.

192.168.1.0/24: network address 192.168.1.0, broadcast address 192.168.1.255, usable range 192.168.1.1–192.168.1.254, 254 devices in total. The same address at /25 would split into two networks of 126 devices each.

Worth knowing

  • The network and broadcast addresses can't be assigned to a device, so the usable count is always 2ⁿ − 2, where n is the number of host bits left.
  • /31 and /32 are special cases, used for point-to-point links and single-host entries; the usual usable-range rule doesn't apply to them.
  • Shrinking the prefix by one (say /24 to /23) doubles the number of usable addresses.

More guides