All posts

Subnetting Without the Headache: A Practical CIDR Guide

July 8, 2026 · DevTools

networking
subnetting
cidr
ipv4
ipv6

Subnetting trips up even experienced engineers, because a single wrong bit in the mask silently changes the network address, the broadcast address, and how many hosts you can actually assign. Here's a practical mental model — and the edge cases that bite.

CIDR in one sentence

CIDR notation like 192.168.1.0/24 means "the first 24 bits are the network, the remaining 8 bits are the host." That /24 is the prefix length. The mask 255.255.255.0 is just those 24 one-bits written in dotted decimal.

192.168.1.0/24
  network bits │ host bits
  11111111 11111111 11111111 │ 00000000

With 8 host bits you get 2⁸ = 256 addresses. But two are reserved:

  • Network address (all host bits 0) — 192.168.1.0, names the subnet.
  • Broadcast address (all host bits 1) — 192.168.1.255, reaches every host.

So 254 usable hosts, 192.168.1.1 through 192.168.1.254.

Deriving the network from any host address

Given 172.16.5.130/22, what's the network? A /22 mask covers the third octet only partially (11111100), so:

  • Network: 172.16.4.0
  • Broadcast: 172.16.7.255
  • Range spans four full /24 blocks (4, 5, 6, 7)

Doing this by hand is error-prone — paste it into the Subnet Calculator and read the network, broadcast, mask and wildcard at a glance, with a bit map that shows exactly where the split falls.

The edge cases everyone forgets

/31 — point-to-point links. Normally you'd say a /31 has "no usable hosts" (2 addresses, both reserved). But RFC 3021 explicitly allows both addresses on point-to-point links, giving you 2 usable hosts. This is the standard sizing for a router-to-router connection and saves address space.

/32 — host routes. A /32 is a single address — a "host route." You'll see these in firewall rules, loopback interfaces, and BGP advertisements for a single IP.

A good calculator handles both correctly instead of blindly subtracting 2 for the network and broadcast.

Wildcard masks

ACLs (and OSPF) often want the inverse of the subnet mask — the wildcard mask. For /24 that's 0.0.0.255. It's just the mask with every bit flipped:

subnet mask   255.255.255.0   → 11111111.11111111.11111111.00000000
wildcard mask 0.0.0.255       → 00000000.00000000.00000000.11111111

A word on IPv6

IPv6 drops broadcast entirely and uses enormous prefixes. A /64 — the standard for a single LAN — contains 2⁶⁴ addresses (about 18 quintillion). You rarely subnet for host counts; you subnet for structure. The Subnet Calculator's IPv6 mode shows the compressed and expanded prefix and the total address count so you can sanity-check an allocation.

Quick reference

PrefixMaskUsable hosts
/24255.255.255.0254
/25255.255.255.128126
/26255.255.255.19262
/30255.255.255.2522
/31255.255.255.2542 (RFC 3021)
/32255.255.255.2551 (host route)

Keep the table handy — or skip the arithmetic entirely and let the Subnet Calculator do it, right in your browser.

Tools mentioned in this post