CIDR and Subnet Masks Explained with Worked Examples

How prefix lengths map to masks, how to compute network, broadcast and usable host ranges, and common sizing mistakes.

Prefix = mask

/24 means the first 24 bits are network bits: mask 255.255.255.0, 256 addresses. Usable hosts = 2^(32−prefix) − 2 (network and broadcast reserved) — except for /31 point-to-point links and /32 host routes.

Sizing mistakes

Off-by-one on prefix length halves or doubles the space. Always reserve for growth: a /23 costs one bit and doubles your addresses. The calculator shows binary breakdown so the arithmetic is visible.

IPv6 shorthand

Leading zeros per group can drop, and one run of zero groups collapses to ::. RFC 5952 mandates the longest-run rule and lowercase hex — the compressor follows it exactly.

Related tools