Contents

CIDR Cheat Sheet: Prefixes, Subnet Masks and Usable Hosts

A practical CIDR cheat sheet: prefix sizes from /16 to /32, subnet masks, wildcard masks and usable hosts, plus how to read 0.0.0.0/0 and plan cloud subnets.

A CIDR cheat sheet maps each prefix length to three things you actually use: the dotted subnet mask, the wildcard mask, and the number of usable hosts. The core pattern is simple — every step down in prefix doubles the address count, and usable hosts equal total addresses minus two (network and broadcast), except /31 and /32. So /24 gives 256 addresses and 254 usable hosts, /25 gives 128 and 126, /26 gives 64 and 62, and /30 gives 4 and 2.

CIDR (Classless Inter-Domain Routing) notation replaced the old class A/B/C address-and-mask pairing: instead of writing 255.255.255.0, you write /24, where 24 is the number of leading bits used for the network and the remaining bits go to hosts. The tables below cover the ranges you meet in practice — from /16 through /32 — with netmask, wildcard mask and host counts, plus the special cases (/31 point-to-point links, /32 single hosts, 0.0.0.0/0 default route) and how to size subnets on cloud servers without wasting address space.

Key points

  • Usable hosts = 2^(32 − prefix) − 2 for every prefix from /0 to /30; /31 and /32 are the exceptions.
  • The wildcard mask is the inverse of the subnet mask, and the block size is 256 minus the mask octet value.
  • 0.0.0.0/0 is the default route covering all 4,294,967,296 IPv4 addresses, not a host address.
  • In cloud networks, a /24 gives 254 usable addresses before provider reservations — plan headroom and avoid overlapping ranges.

How to read CIDR notation in one line

An IPv4 address is 32 bits written as four octets. The suffix after the slash says how many of those bits are fixed as the network portion; the rest identify hosts. In 192.168.1.12/24, the first 24 bits (192.168.1) are the network and the last 8 bits are the host, so the address sits in the 192.168.1.0/24 network with mask 255.255.255.0 — 192.168.1.0 is the network address and 192.168.1.255 is the broadcast address.

Two shortcuts save most of the mental arithmetic. First, the wildcard mask is the bitwise inverse of the subnet mask: /24 gives 255.255.255.0 and 0.0.0.255. Second, the block size in the last octet is 256 minus the mask value in that octet — 256 − 192 = 64 for /26, 256 − 224 = 32 for /27, 256 − 240 = 16 for /28. That block size is the subnet step, which is why /26 subnets start at .0, .64, .128 and .192.

  • Prefix = number of network bits; 32 − prefix = host bits
  • Total addresses = 2^(32 − prefix)
  • Usable hosts = total − 2 (network + broadcast), except /31 and /32
  • Wildcard mask = inverse of the subnet mask

CIDR cheat sheet table: /16 to /32

The table below is the reference most engineers keep open: prefix, subnet mask, wildcard mask, total addresses and usable hosts. Values match the standard published charts (freeCodeCamp's subnet cheat sheet and OpenSysTools' IPv4 reference use the same figures). For prefixes longer than /24 the subnet mask stays 255.255.255.x and only the last octet changes; for /16 and shorter the change moves into earlier octets.

One rule covers every row: usable hosts are total addresses minus two. That is why /16 gives 65,536 addresses but 65,534 usable hosts, and /28 gives 16 addresses but 14 usable hosts. If you are sizing a cloud server or a private network and want to see how address space translates into billable resources, the Cloud Hosting Cost Calculator turns instance and network choices into a monthly figure.

  • /24 is the default for small LANs and VPC subnets: 254 usable hosts
  • /25 and /26 are the usual split for public/private tiers
  • /29 and /30 are typical for point-to-point and gateway links
  • /32 identifies a single host, used in firewall and routing rules

Special prefixes: /31, /32 and 0.0.0.0/0

/31 and /32 break the minus-two rule. A /31 has 2 addresses and, per RFC 3021, both can be assigned on a point-to-point link — there is no broadcast address, so usable hosts equal 2. A /32 has exactly 1 address and represents a single host: it appears in host routes, firewall rules and allow-lists, not on a LAN segment.

0.0.0.0/0 is the default route — zero network bits fixed, all 32 bits free, covering every IPv4 address (4,294,967,296 in total). In a routing table or a cloud security group it means "anywhere". A common mistake is writing 0.0.0.0 as a host address; as a destination it is the default route, and as a source it means "this host, address not yet known". If you are tightening firewall rules on a hosted server, the cloud hosting security checklist covers the same allow-list logic in more depth.

  • 0.0.0.0/0 = default route / any IPv4 address
  • 127.0.0.0/8 = loopback range
  • 169.254.0.0/16 = link-local (APIPA)
  • 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 = private ranges

Subnetting a /24 by hand: /25 through /30

Splitting a /24 is the exercise that appears in every CCNA-style test and in real VPC design. Each halving doubles the subnet count and halves the hosts: /25 gives 2 subnets of 126 hosts, /26 gives 4 of 62, /27 gives 8 of 30, /28 gives 16 of 14, /29 gives 32 of 6, /30 gives 64 of 2. The network addresses step by the block size, and the broadcast address is one below the next network address.

For 192.168.1.0/26, the four subnets are .0 (hosts .1–.62, broadcast .63), .64 (hosts .65–.126, broadcast .127), .128 (hosts .129–.190, broadcast .191) and .192 (hosts .193–.254, broadcast .255). Note that the first usable host of each subnet is the network address plus one — a fast sanity check when a host "can't reach" a gateway that was assigned the network address by mistake.

  • Block size in last octet = 256 − mask octet value
  • Broadcast = next network address − 1
  • First usable host = network address + 1
  • Last usable host = broadcast address − 1

Sizing cloud subnets with CIDR

Cloud networks inherit IPv4 subnetting directly: a VPC subnet declared as 10.0.1.0/24 has 254 usable addresses, and providers reserve a few of them for internal routing, so plan headroom rather than filling a /24 exactly. Public-facing tiers typically get a /24 or /25, private application tiers a /24, and database or management subnets a /28 or smaller. Overlapping ranges across VPCs and on-premises networks are the most common cause of failed peering, so allocate from a single address plan before you build.

Address planning also affects cost, because larger instances and more network interfaces mean more billable resources. The scalability planning guide explains how to size for growth, and the step-by-step cost guide shows how to model the monthly impact. If you are comparing plans before you commit, managed vs unmanaged hosting matters too: on unmanaged servers, subnet and firewall configuration is your job.

  • Reserve one /16 per environment (prod, staging, dev) and carve /24s inside
  • Keep private ranges (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16) consistent across regions
  • Leave at least one unused /24 between adjacent subnets for growth
  • Document the plan; undocumented CIDR maps drift within months

Common CIDR mistakes to check first

Most "network is down" tickets trace back to a handful of CIDR errors. Assigning a network or broadcast address to a host, using a /24 mask on a /25 subnet, or allowing 0.0.0.0/0 into a management port all produce symptoms that look like outages. The subnet definition on Wikipedia is a reliable refresher on network, broadcast and host boundaries if a colleague questions the arithmetic.

The wildcard mask trips people up in ACLs because it is the opposite of a subnet mask: 0.0.0.255 matches the last octet, not 255.255.255.0. Cisco-style access lists and some firewall UIs use wildcard masks, so write both columns on your cheat sheet. A quick reference on wildcard masks explains the inversion rule.

  • Host on the network address → no connectivity
  • Host on the broadcast address → no connectivity
  • Mask mismatch between host and gateway → intermittent failures
  • 0.0.0.0/0 open on SSH or database ports → exposure
  • Wildcard mask confused with subnet mask → ACL matches nothing

Frequently asked questions

Can you provide a cheat sheet for CIDR notation? The table above is the cheat sheet: for each prefix from /16 to /32 it lists the subnet mask, wildcard mask, total addresses and usable hosts. The two rules to memorize are that usable hosts equal total addresses minus two (except /31 and /32), and that each step down in prefix doubles the address count.

Can you explain CIDR in a simple way? CIDR is shorthand for a subnet mask: /24 means the first 24 of the 32 bits in an IPv4 address identify the network, and the last 8 identify hosts. Instead of writing 192.168.1.12 with mask 255.255.255.0, you write 192.168.1.12/24. The bigger the number after the slash, the smaller the network.

Is 0.0.0.0/0 a valid CIDR? Yes. 0.0.0.0/0 fixes zero network bits, so it covers every IPv4 address — 4,294,967,296 in total — and is used as the default route or as "any source/destination" in firewall and security group rules. It is valid, but opening it to management ports such as SSH or a database listener is a common security mistake.

1022/22254/24126/2562/2630/2714/28
Usable hosts per CIDR prefix (each step down in prefix doubles the count) (usable hosts)
CIDR cheat sheet: prefix, subnet mask, wildcard mask, total addresses and usable hosts
PrefixSubnet maskWildcard maskTotal addressesUsable hosts
/16255.255.0.00.0.255.25565,53665,534
/22255.255.252.00.0.3.2551,0241,022
/24255.255.255.00.0.0.255256254
/26255.255.255.1920.0.0.636462
/28255.255.255.2400.0.0.151614
/30255.255.255.2520.0.0.342
/32255.255.255.2550.0.0.011
Alex Morgan

Senior Cloud Consultant

Alex has over a decade of experience helping businesses migrate to and optimize cloud infrastructure. He writes about practical cloud hosting strategies and cost management. His focus is on making cloud technology accessible to small and medium enterprises.

Cloud Hosting Cost Calculator

Cookie Preferences

Required for the site to function, such as remembering your cookie consent choice.

Not used on this site.

Not used on this site.