Subnetting Cheatsheet: Sizes, Masks, and Conversions

A practical reference for IPv4 subnetting: prefix lengths, host counts, common masks, and the conversions that come up in real network design.

Subnetting Cheatsheet: Sizes, Masks, and Conversions

You’re designing a network. You need a /22 subnet but you don’t remember offhand how many hosts that is. Or you’re given a netmask 255.255.252.0 and need to translate to CIDR. Or you’re sizing a cloud VPC and need to plan subnets.

This post is the cheatsheet. Prefix length → mask → host count, all the common sizes, in one place, with the conversions you’ll actually need.

The Prefix Length Table

IPv4 prefix lengths, in order:

CIDRNetmaskWildcardTotal addressesUsable hostsCommon use
/32255.255.255.2550.0.0.011Single host
/31255.255.255.2540.0.0.122*Point-to-point links
/30255.255.255.2520.0.0.342Point-to-point
/29255.255.255.2480.0.0.786Small VLAN
/28255.255.255.2400.0.0.151614Small DMZ
/27255.255.255.2240.0.0.313230Small office subnet
/26255.255.255.1920.0.0.636462Medium subnet
/25255.255.255.1280.0.0.127128126Half a /24
/24255.255.255.00.0.0.255256254Standard LAN
/23255.255.254.00.0.1.255512510Larger LAN
/22255.255.252.00.0.3.2551,0241,022Building network
/21255.255.248.00.0.7.2552,0482,046Campus subnet
/20255.255.240.00.0.15.2554,0964,094Medium VPC
/19255.255.224.00.0.31.2558,1928,190Large VPC
/18255.255.192.00.0.63.25516,38416,382Very large LAN
/17255.255.128.00.0.127.25532,76832,766Massive subnet
/16255.255.0.00.0.255.25565,53665,534Class B equivalent
/15255.254.0.00.1.255.255131,072131,070Multiple /16s
/14255.252.0.00.3.255.255262,144262,142Large org
/13255.248.0.00.7.255.255524,288524,286Huge org
/12255.240.0.00.15.255.2551,048,5761,048,574RIR allocation
/8255.0.0.00.255.255.25516,777,21616,777,214Class A equivalent

* /31 in RFC 3021 mode allows 2 usable hosts on point-to-point links (no network/broadcast).

For the underlying concepts of CIDR notation and netmasks, see subnet mask CIDR explained.

Why “Usable Hosts” Is Less Than “Total Addresses”

In standard IPv4, each subnet reserves:

  • Network address (first address) — Identifies the subnet itself.
  • Broadcast address (last address) — Sends to all hosts on the subnet.

So a /24 with 256 addresses has 254 usable hosts: 192.168.1.0 (network) and 192.168.1.255 (broadcast) are reserved; 192.168.1.1-254 are usable.

Exceptions:

  • /31 (RFC 3021): for point-to-point links. No broadcast needed; both addresses usable.
  • /32: single host; concept of network/broadcast doesn’t apply.

Common Cloud Subnet Choices

AWS VPC sizing

  • VPC: /16 to /28. Default new VPCs are /16.
  • Subnets within VPC: /16 to /28. Each subnet must be in one Availability Zone.
  • Common subnet size: /24 (256 addresses) or /20 (4096 addresses).
  • AWS reserves 5 addresses per subnet for AWS internal use, in addition to the network/broadcast.

So a /24 in AWS gives you 251 usable host IPs.

GCP and Azure

Similar conventions. GCP subnets are typically /24 to /20. Azure subnets reserve 5 addresses too.

Kubernetes pod CIDRs

  • /14 for the whole cluster (4096 pods × 4096 hosts).
  • /22 to /24 per node (pods on that node).

Specific numbers vary by CNI plugin; the orders of magnitude are similar.

Converting Between Forms

CIDR to host count

hosts = 2^(32 - cidr) - 2 (for cidr ≤ 30).

/222^10 - 2 = 1022 usable hosts.

Host count to CIDR

Round up to next power of 2, then cidr = 32 - log2(hosts + 2).

Need 100 hosts → 128 addresses → /25 (with 126 usable hosts).

Netmask to CIDR

Count the 1-bits in the binary netmask.

255.255.252.0 = 11111111.11111111.11111100.00000000 = 22 ones → /22.

CIDR to netmask

Number of 1-bits then 0-bits, packed into octets.

/22 = 22 ones then 10 zeros → 11111111.11111111.11111100.00000000255.255.252.0.

Calculating Network Address from IP + CIDR

To find which subnet an IP belongs to:

IP:     203.0.113.42
CIDR:   /27 (224 in last octet)

42 / 32 = 1 remainder 10
Network: 203.0.113.32 (first multiple of 32 ≤ 42)
Range: 203.0.113.32 - 203.0.113.63

Or programmatically with ipaddress in Python:

import ipaddress
net = ipaddress.ip_network('203.0.113.42/27', strict=False)
print(net.network_address)  # 203.0.113.32
print(net.broadcast_address) # 203.0.113.63

Subnet Adjacency

For multi-region networks where you need non-overlapping CIDRs:

A /16 covers 65536 addresses. Splitting into /24s gives you 256 /24 subnets. Splitting into /20s gives 16 /20 subnets.

Example allocation plan for a multi-region deployment:

us-east:   10.0.0.0/16   (10.0.0.0 - 10.0.255.255)
us-west:   10.1.0.0/16   (10.1.0.0 - 10.1.255.255)
eu-west:   10.2.0.0/16   (10.2.0.0 - 10.2.255.255)
ap-south:  10.3.0.0/16   (10.3.0.0 - 10.3.255.255)

Each /16 can be subdivided into /20s, /24s, etc., for AZ subnets within the region.

Variable Length Subnet Masking (VLSM)

You don’t have to give every subnet the same size. VLSM lets you allocate efficiently:

Building network: 192.168.0.0/22  (1024 addresses)
  HR (50 users):  192.168.0.0/26  (64 addresses)
  Engineering (200): 192.168.0.64/25  (128 addresses)
  Wait — overlaps. Better:
  Engineering: 192.168.1.0/24 (256 addresses)
  Sales (100): 192.168.2.0/25 (128 addresses)
  Servers: 192.168.3.0/24 (256 addresses)

VLSM is standard practice in 2026. Modern routers handle arbitrary prefix lengths.

IPv6 Sizing

IPv6 uses different conventions:

  • /128 — single host.
  • /64 — standard subnet (auto-config requires this).
  • /56 — typical home assignment (256 /64 subnets).
  • /48 — typical enterprise allocation (65,536 /64 subnets).
  • /32 — typical LIR allocation (4 billion /64 subnets).

The IPv6 world doesn’t conserve addresses the way IPv4 does. You always use /64 for end subnets; you delegate /48 or /56 to sites. See IPv6 deployment guide.

Practical Sizing Guide

When designing a new network, ask:

  1. How many hosts in the largest subnet? Pick the smallest CIDR that fits.
  2. How many subnets total? Multiply.
  3. Growth? Add 2-4x headroom.
  4. Multi-region? Make sure regions don’t overlap.
  5. Future VPN peering? Avoid common ranges (10.0.0.0/24, 192.168.1.0/24).

A typical “design a corporate network for 500 employees in 3 offices” looks like:

Corp HQ:       10.10.0.0/16 (potential 65k hosts; we'll use a fraction)
  Engineering: 10.10.10.0/23 (510 hosts)
  Sales:       10.10.20.0/24 (254 hosts)
  Servers:     10.10.30.0/24 (254 hosts)
  Wi-Fi:       10.10.40.0/22 (1022 hosts)

Branch 1:      10.20.0.0/16
Branch 2:      10.30.0.0/16

Each office has plenty of room within its /16. Inter-office VPN connects them without overlap.

Tools

A few practical tools for working with subnets:

  • ipcalc — CLI tool. ipcalc 192.168.0.0/22 gives all the details.
  • sipcalc — More features than ipcalc.
  • Python ipaddress — Programmatic subnet math.
  • Online calculatorssubnet-calculator.com, ipcalc.co.uk.

TL;DR

  • Reference the table for prefix length → mask → host count.
  • Each subnet reserves network + broadcast; usable hosts = total − 2.
  • AWS reserves 5 additional addresses per subnet.
  • /31 for point-to-point (RFC 3021); both addresses usable.
  • VLSM lets you mix subnet sizes for efficient allocation.
  • For multi-region, give each region a non-overlapping /16 or /20.
  • For future VPN peering, avoid common ranges that everyone else picks.
  • IPv6 uses /64 standard subnets; allocate /48 or /56 to sites.

Subnetting is one of those skills that gets fluent with practice. The table above covers 95% of what comes up in modern network design. For the underlying concepts, see subnet mask CIDR explained; for the private ranges most of your networks will live in, private IP ranges RFC 1918.

Get Started

Convert IPs into accurate location data in milliseconds.

Sign up today and get 1,000 free monthly stored conversions, and discover why developers trust us for fast, reliable, and affordable IP conversions.