networkutils.org

Home / Blog / A Practical Subnet Calculation Cheat Sheet

IP

A Practical Subnet Calculation Cheat Sheet

CIDR math is just binary arithmetic with a confidence problem. Walk through the core calculations — host counts, ranges, and splits — with worked examples you can reuse.

Subnetting intimidates people because it is taught as a pile of rules to memorise. Underneath, it is just binary: a mask is a row of 1s followed by 0s, and the boundary between them determines everything else. Once you internalise the boundary, the calculations become mechanical.

The CIDR prefix is the count of 1 bits

A /24 mask means the first 24 bits are network bits and the last 8 are host bits. The number of usable host addresses is 2 to the power of the host bits, minus 2 (network and broadcast). A /24 has 8 host bits: 2^8 = 256, minus 2 = 254 usable hosts. A /22 has 10 host bits: 2^10 = 1024, minus 2 = 1022.

The block size for the network portion is 2 to the power of the host bits. A /26 has 6 host bits, so a block size of 64: networks fall on boundaries of 0, 64, 128, 192. Knowing the block sizes for /24 through /30 by heart covers almost every real-world planning task.

Finding the network and broadcast addresses

Given an address like 10.20.30.140/26, the network address is the address with all host bits set to 0, and the broadcast is all host bits set to 1. With a /26, the block size is 64, and 140 falls in the block starting at 128 (since 128 is the largest multiple of 64 not exceeding 140). So the network is 10.20.30.128, the broadcast is 10.20.30.191, and usable hosts are .129 through .190.

A subnet calculator does this instantly and removes the arithmetic errors that creep in under pressure. Use one to verify hand calculations until the pattern is instinctive.

Splitting a block into smaller subnets

To split a /24 into four equal subnets, you borrow 2 more network bits (since 2^2 = 4), giving /26s. Each /26 has 64 addresses. The four subnets start at .0, .64, .128, and .192. To split into eight, borrow 3 bits for /27s of 32 addresses each. Each additional borrowed bit doubles the count of subnets and halves their size.

When planning, work from the largest subnet down. Allocate your biggest networks first so the smaller ones fit into the remaining gaps without fragmenting the block. This keeps your addressing plan contiguous and makes future aggregation possible.

The special prefixes

A /31 has 2 addresses and no broadcast — it is valid for point-to-point links per RFC 3021, giving you both addresses as usable. A /32 is a single host, used for loopbacks and host routes. Knowing these two exceptions saves you from the “why does this /31 have no usable hosts” confusion that calculators set to the strict RFC 950 rule will surface.

Subnetting is a skill that compounds: get the binary boundary clear, memorise the common block sizes, verify with a calculator, and plan top-down. Do that and you will never second-guess a CIDR range again.