Skip to main content

Subnet Calculator Basics: Reading a CIDR Block From Mask to Host Count

How a CIDR prefix maps to a subnet mask and host count, how to find the network, broadcast, and usable range, and how to plan IP blocks without guessing.

Published By Li Lei
#networking #subnetting #cidr #ip-address

Subnet Calculator Basics: Reading a CIDR Block From Mask to Host Count

The first time I had to carve an office network into per-floor blocks, I did the arithmetic on a sticky note, transposed a bit, and handed out two overlapping ranges. The DHCP server happily leased addresses out of both and two printers fought over the same IP for a week. The math behind a subnet is not hard, but it is unforgiving, and the place people slip is almost always the boundary: which address is the network, which is the broadcast, and how many are left for actual machines.

This is a walk through what a CIDR block actually says, so the numbers a subnet calculator hands you stop being magic and start being checkable.

What the slash actually means

Write an address as 192.168.1.0/24. The number after the slash is the prefix length: how many of the 32 bits in an IPv4 address are fixed for the network. A /24 fixes the first 24 bits, leaving 8 bits free for hosts. Those 8 free bits are where every address inside the block lives.

The prefix length and the dotted subnet mask are two ways of saying the same thing. A /24 is 255.255.255.0: the first three octets are all ones (network), the last octet is all zeros (host). Convert the mask to binary and the boundary is literally visible — 11111111.11111111.11111111.00000000. The count of leading ones is the prefix length. That is the whole relationship.

The wildcard mask is the same bits flipped: 0.0.0.255 for a /24. Cisco access lists and OSPF statements want the wildcard, not the mask, and pasting one where the other belongs is a silent, classic mistake.

Host count: every bit halves the block

Free host bits set the size of the block. With h host bits you get 2^h total addresses. A /24 keeps 8 host bits, so 2^8 = 256 addresses. Of those, a /24 has 256 addresses and 254 usable ones — the first address (all host bits zero) is the network identifier and the last (all host bits one) is the broadcast. Neither can sit on a real interface.

Now watch what one more network bit does. Move from /24 to /25 and you have borrowed a host bit; 7 host bits remain, 2^7 = 128 addresses. Each bit you borrow for the network halves the block. Borrow another for /26 and you are at 64. The pattern is mechanical:

  • /24 → 256 addresses, 254 usable
  • /25 → 128 addresses, 126 usable
  • /26 → 64 addresses, 62 usable
  • /27 → 32 addresses, 30 usable
  • /28 → 16 addresses, 14 usable

Usable always equals total minus 2, with two exceptions worth knowing. A /31 has only 2 addresses and, under RFC 3021, both are usable — it exists for point-to-point links where there is no room to waste on a broadcast. A /32 is a single host route: one address, used for loopbacks and host-specific firewall rules.

A worked example: 192.168.1.0/26

Take 192.168.1.0/26. The prefix is 26, so 6 host bits remain and 2^6 = 64 addresses. The block runs from 192.168.1.0 to 192.168.1.63.

  • Network address: 192.168.1.0 — host bits all zero, names the subnet.
  • Broadcast address: 192.168.1.63 — host bits all one, the last address in the block.
  • Usable host range: 192.168.1.1 to 192.168.1.62.
  • Usable count: 62 (64 − 2).
  • Mask: 255.255.255.192; wildcard: 0.0.0.63.

The .63 falls out cleanly: 64 addresses starting at .0 end at .63. The next /26 would be 192.168.1.64/26, then 192.168.1.128/26, then 192.168.1.192/26 — four /26 blocks tile a full /24. That tiling is the heart of subnetting: a parent splits into a power-of-two number of equal children, and each child's starting address is the previous broadcast plus one.

Planning ranges without collisions

Real planning runs in one of two directions, and it helps to be honest about which one you are doing.

If you know how many subnets you need, you borrow bits. Splitting a /24 into four equal segments needs 2 borrowed bits (2^2 = 4), giving four /26 blocks of 62 hosts each. Eight segments need 3 bits, giving /27s of 30 hosts each.

If you know how many hosts each segment must hold, you size the prefix to fit. A floor with 50 devices needs at least 50 usable addresses; a /26 gives 62 and a /27 only 30, so /26 is the smallest prefix that fits. Always round up — there is no half-bit, and underestimating means re-IPing later, which is exactly the pain you were trying to avoid.

The discipline that prevents the overlapping-range bug I caused: every block must start on a valid boundary for its size. A /26 can only begin at an address that is a multiple of 64 in its last octet — .0, .64, .128, .192. Start a /26 at .32 and it straddles two legitimate blocks, and any tool computing the network address will quietly snap it back, so your spreadsheet and your router will disagree.

Checking your work

A calculator earns its keep on the edges. Before I commit a plan I verify three things by hand and let the tool confirm the rest: the broadcast is the network plus the block size minus one, the usable count is total minus two (except /31 and /32), and adjacent blocks meet without a gap or overlap — child two's network is child one's broadcast plus one.

Bit operations are also why this math is safe to run locally. There is no lookup, no API; a /26 is just 192.168.1.0 with the low 6 bits masked off. If you are auditing a config file and need to pull every address out of it first, an IPv4 address extractor gets you the raw list, and the subnet calculator tells you which block each one belongs to.

Subnetting rewards a little paranoia. Count the addresses twice, confirm the boundary, and a block that looks right on paper will behave the same way on the wire.


Made by Toolora · Updated 2026-06-13