Subnet Mask Cheat Sheet: Every CIDR Prefix /0 to /32

Subnet Mask Cheat Sheet

This subnet mask cheat sheet lists every CIDR prefix from /0 to /32. Filter by CIDR, mask, wildcard, or host count.

Quick reference (most-looked-up masks):
  • /24 = 255.255.255.0 — 254 usable hosts
  • /25 = 255.255.255.128 — 126 usable hosts
  • /26 = 255.255.255.192 — 62 usable hosts
  • /30 = 255.255.255.252 — 2 usable hosts
  • /31 = 255.255.255.254 — 2 hosts (point-to-point)
CIDRSubnet MaskWildcard MaskTotal AddressesUsable HostsCopy
/00.0.0.0255.255.255.2554,294,967,2964,294,967,294
/1128.0.0.0127.255.255.2552,147,483,6482,147,483,646
/2192.0.0.063.255.255.2551,073,741,8241,073,741,822
/3224.0.0.031.255.255.255536,870,912536,870,910
/4240.0.0.015.255.255.255268,435,456268,435,454
/5248.0.0.07.255.255.255134,217,728134,217,726
/6252.0.0.03.255.255.25567,108,86467,108,862
/7254.0.0.01.255.255.25533,554,43233,554,430
/8255.0.0.00.255.255.25516,777,21616,777,214
/9255.128.0.00.127.255.2558,388,6088,388,606
/10255.192.0.00.63.255.2554,194,3044,194,302
/11255.224.0.00.31.255.2552,097,1522,097,150
/12255.240.0.00.15.255.2551,048,5761,048,574
/13255.248.0.00.7.255.255524,288524,286
/14255.252.0.00.3.255.255262,144262,142
/15255.254.0.00.1.255.255131,072131,070
/16255.255.0.00.0.255.25565,53665,534
/17255.255.128.00.0.127.25532,76832,766
/18255.255.192.00.0.63.25516,38416,382
/19255.255.224.00.0.31.2558,1928,190
/20255.255.240.00.0.15.2554,0964,094
/21255.255.248.00.0.7.2552,0482,046
/22255.255.252.00.0.3.2551,0241,022
/23255.255.254.00.0.1.255512510
/24255.255.255.00.0.0.255256254
/25255.255.255.1280.0.0.127128126
/26255.255.255.1920.0.0.636462
/27255.255.255.2240.0.0.313230
/28255.255.255.2400.0.0.151614
/29255.255.255.2480.0.0.786
/30255.255.255.2520.0.0.342
/31255.255.255.2540.0.0.122
/32255.255.255.2550.0.0.011
Showing all 33 prefixes (/0 to /32).

Subnet mask octet values

Each subnet mask octet is one of nine values. The value depends on how many bits are set inside that octet. Use this table to read or build any mask by hand.

Mask OctetBinaryWildcard OctetNetwork Bits
0000000002550
128100000001271
19211000000632
22411100000313
24011110000154
2481111100075
2521111110036
2541111111017
2551111111108

How to read this subnet mask cheat sheet

Each row maps one CIDR prefix to its subnet mask, wildcard mask, total address count, and usable host count. The prefix counts the network bits. The remaining bits become host bits that number the devices inside the subnet.

Read the table in either direction. Start from a CIDR prefix like /26 to find its mask. Or start from a mask like 255.255.255.192 to find its prefix. The subnet calculator works out full ranges for a specific address.

How to calculate usable hosts

Usable hosts equal 2 raised to the host-bit count, minus 2. Host bits equal 32 minus the prefix length. The subtraction removes the network address and the broadcast address, which cannot be assigned to devices.

A /24 has 8 host bits, so it holds 256 addresses and 254 usable hosts. A /26 has 6 host bits, giving 64 addresses and 62 usable hosts. Two prefixes break this rule.

The /31 exception (point-to-point links)

A /31 gives both addresses to hosts, so it has two usable hosts, not zero. RFC 3021 defined this for point-to-point links. It saves address space, since each router link needs only two addresses. Cisco IOS has supported it since release 12.2(2)T.

The /32 exception (host routes)

A /32 describes a single address with the mask 255.255.255.255. It has one usable host. Engineers use it for host routes, loopback interfaces, and firewall rules that match one exact IP.

Wildcard masks and where you use them

A wildcard mask is the inverse of a subnet mask. Subtract each mask octet from 255 to get it. A 0 bit means the position must match, and a 1 bit means it can vary. Cisco access lists and OSPF network statements use wildcard masks.

For a /24, the subnet mask 255.255.255.0 becomes the wildcard mask 0.0.0.255. Convert any mask with the IP binary converter, or plan blocks with the CIDR to IP range converter.

Worked subnet mask examples

These examples show how to move between prefix, mask, and host count using the cheat sheet above.

  • Need 50 hosts: a /26 gives 62 usable hosts, the smallest fit. A /27 gives only 30.
  • Given 255.255.255.240: that octet sets 4 bits, so the prefix is /28 with 14 usable hosts.
  • Router link: use a /30 for 2 usable hosts, or a /31 to save two addresses per link.

Common subnet mask mistakes

Two errors cause most subnetting confusion. Watch for both when you read the cheat sheet.

  • Forgetting the minus 2: total addresses include the network and broadcast. Usable hosts are always two fewer, except on a /31 and /32.
  • Confusing the two masks: a subnet mask starts with 255s, while a wildcard mask starts with 0s. Cisco tools expect the wildcard form.

Related tools and resources

Explore more free networking tools. Size a network with the subnet calculator. Expand a block with the CIDR to IP range converter. Convert addresses with the IP binary converter. Look up services with the port number reference. To go deeper, read the subnetting beginner’s guide or VLSM and supernetting. Related background covers public vs private IP addresses, IPv4 vs IPv6, and how masks shape firewall rules.

References

  • RFC 1878 — Variable Length Subnet Table for IPv4.
  • RFC 4632 — Classless Inter-Domain Routing (CIDR).
  • RFC 3021 — Using 31-bit prefixes on IPv4 point-to-point links.

Subnet mask cheat sheet FAQ

What is the subnet mask for a /24?
A /24 uses the subnet mask 255.255.255.0. It provides 256 total addresses and 254 usable host addresses. The matching wildcard mask is 0.0.0.255.
How many usable hosts are in a /26 subnet?
A /26 subnet has 64 total addresses and 62 usable hosts. Two addresses are reserved for the network and broadcast. Its subnet mask is 255.255.255.192.
What is a wildcard mask?
A wildcard mask is the inverse of a subnet mask. You subtract each mask octet from 255. Cisco access lists and OSPF use wildcard masks to match address ranges.
Why does a /31 have two usable hosts?
A /31 has two usable hosts because RFC 3021 removes the network and broadcast reservation on point-to-point links. Both addresses become valid host addresses. This conserves scarce IPv4 space.
How do I calculate the number of usable hosts?
Usable hosts equal 2 raised to the number of host bits, minus 2. Host bits equal 32 minus the prefix length. The minus 2 covers the network and broadcast addresses. A /31 and a /32 are exceptions.
What is the difference between a subnet mask and CIDR notation?
A subnet mask and CIDR notation express the same boundary in two formats. The mask 255.255.255.0 equals the CIDR prefix /24. CIDR counts the network bits, while the mask shows them in dotted decimal.
Secret Link