Ch. 20 · Networking

Networking: IP Subnetting and CIDR

Read CIDR notation, compute usable host ranges, and design non-overlapping subnets for a VPC.

~2 min readintermediateupdated Oct 5, 2026

CIDR notation writes an address and the number of network bits, such as 10.0.0.0/16. The remaining bits identify hosts, so the prefix length fixes the block size. Subnetting divides a block into smaller ranges, and the arithmetic decides how many hosts each range can hold.

Before you start

You should be comfortable with binary and decimal. This article covers IPv4 subnetting; the same idea applies to IPv6 with larger numbers.

Step-by-step walkthrough

Step 1: Read the prefix length

A /24 leaves eight host bits, so the block has 256 addresses. A /16 leaves sixteen host bits, so it has 65,536. The prefix length and the block size are inversely related: each bit you add to the prefix halves the block.

Step 2: Subtract the reserved addresses

In a /24, two addresses are reserved: the network address (all host bits zero) and the broadcast address (all host bits one), leaving 254 usable hosts. IPv6 has no broadcast, so its usable count differs, but the subnet’s anycast and reserved addresses still apply.

Step 3: Design non-overlapping subnets

When you carve a VPC into subnets, keep them disjoint so routing is unambiguous. Overlapping subnets cause traffic to a range to be routed unpredictably. Plan the ranges up front and reserve room to grow, rather than allocating too tightly and having to re-address later.

Worked scenario

The /24 block leaves 254 usable addresses.

10.0.0.0/24
  network:   10.0.0.0
  broadcast: 10.0.0.255
  usable:    10.0.0.1 - 10.0.0.254   (254 hosts)
Text

Walk through the example

The prefix /24 fixes the first three octets as the network part, so the last octet ranges over 0–255. The lowest and highest are reserved, leaving 254 hosts. A /25 would split this into two blocks of 128, each with 126 usable hosts.

Common mistake

Counting the network and broadcast addresses as usable, which overstates capacity by two per subnet, or allocating subnets that overlap, which causes routing ambiguity. In IPv6, forgetting that host counts are astronomical and that planning is about structure, not scarcity, is another common slip.

Verify the behavior

Compute the usable range for a /26 and confirm it is 62 hosts. Check that two planned subnets do not overlap by comparing their ranges. Confirm the broadcast address of a subnet is not assigned to a host.

Interview exercise

How many usable hosts does a /26 provide?

Answer and reasoning

A /26 leaves six host bits, so the block has 2^6 = 64 addresses. Subtracting the network and broadcast addresses leaves 62 usable hosts. The pattern is 2^(32 − prefix) − 2 for IPv4, remembering the reservation.

Continue learning

Compare routing in VPC routing and address placement in Node placement. Read the Cloudflare CIDR documentation and try the Networking interview questions.

More in Networking

read ✓Networking · mid

Networking: DNS Caching and TTL

Understand positive and negative caching, why changes are not instant, and how TTL trades propagation speed against query load.

~2 min readread →
read ✓Networking · easy

Networking: DNS Record Types

Read and choose DNS records: A and AAAA for addresses, CNAME for aliases, and MX and TXT for mail and verification.

~2 min readread →
read ✓Networking · mid

Networking: HTTP Redirects

Choose between 301, 302, 307 and 308, know which preserve the request method, and avoid caching and loop mistakes.

~2 min readread →
esc