CIDR and IPv4 Subnetting: Worked Examples for Developers

Reviewed September 3, 2026 · Maintained by William

CIDR notation combines an IPv4 address with a prefix length. The prefix says how many leading bits identify the network.

/24 example

192.168.10.25/24 uses mask 255.255.255.0. The network is 192.168.10.0 and the traditional broadcast address is 192.168.10.255.

/26 example

A /26 leaves 6 host bits, so each block contains 64 addresses. The last octet boundaries are 0, 64, 128 and 192.

192.168.10.70/26
network:   192.168.10.64
broadcast: 192.168.10.127
range:     192.168.10.64 - 192.168.10.127

In a traditional subnet, addresses between network and broadcast are host addresses, but provider-specific reservations can reduce assignable counts.

/30 example

A /30 has four addresses per block. For 10.0.0.6/30, the block is 10.0.0.4–10.0.0.7, with the traditional usable pair .5 and .6.

/31 and /32 are edge cases

A simplistic “subtract network and broadcast” rule breaks down for modern point-to-point /31 use described by RFC 3021. A /32 identifies one address. Calculators should show the arithmetic and avoid overgeneralizing “usable hosts.”

What subnet math cannot tell you

  • Which routes your router will announce.
  • Which addresses a cloud provider reserves.
  • Whether NAT, firewall rules or VLANs make the address reachable.
  • Whether an address is appropriate for public use.

The CIDR Range Calculator and IP Subnet Calculator focus on standard IPv4 arithmetic and explicitly separate that from routing policy.

References

Worked /24 example

For 192.168.20.42/24, the first 24 bits identify the network. The mask is 255.255.255.0, so the network is 192.168.20.0 and the broadcast address is 192.168.20.255. In traditional host-addressing terms, the range between them is 192.168.20.1 through 192.168.20.254.

Worked /26 example

A /26 leaves 6 host bits, giving blocks of 64 addresses. In the last octet the block boundaries are 0, 64, 128 and 192.

Input:     192.168.10.77/26
Block:     192.168.10.64 - 192.168.10.127
Network:   192.168.10.64
Broadcast: 192.168.10.127
Traditional host range: 192.168.10.65 - 192.168.10.126

The useful mental shortcut is block size, but binary reasoning is more general: mask off the host bits for the network and set host bits to 1 for the broadcast address.

Worked /30 example

A /30 has four addresses per block. 10.0.0.9/30 falls in the block 10.0.0.8–10.0.0.11. Traditionally, .8 is network, .11 broadcast and .9–.10 are host addresses. /30 is therefore common in older point-to-point subnetting examples.

/31 and /32 are special cases

Do not mechanically subtract two usable addresses for every prefix. RFC 3021 defines /31 use for point-to-point links, where both addresses can be endpoints and the traditional network/broadcast distinction is not used the same way. A /32 identifies one IPv4 address. Calculators should surface these caveats rather than applying a classroom formula blindly.

Cloud “usable address” counts can differ

Cloud providers may reserve addresses inside a subnet for platform functions. CIDR math describes the address block; provider policy describes what you may assign. When planning capacity, use the provider’s current subnet-reservation documentation in addition to the calculated range.

Subnet debugging checklist

  • Write the prefix and dotted mask explicitly.
  • Calculate the containing block boundary, not just the host count.
  • Check whether the target IP is actually inside the expected range.
  • Separate subnet arithmetic from routing, firewall, VLAN and NAT policy.
  • For /31-/32, apply the intended operational use rather than generic “network/broadcast” assumptions.

Use the CIDR Range Calculator or IP Subnet Calculator to check arithmetic, then validate routing and platform reservations in the environment where the network will exist.

About the review

This guide is maintained by William. Technical claims are checked against primary or authoritative references where applicable. See How We Test CodeNimbleTools for the site-wide review and correction process.