Technical Guide

Subnet Mask Cheat Sheet: CIDR, Hosts & IPv4 Quick Reference

SUBNET MASK REFERENCE

A subnet mask tells you where the network portion of an IPv4 address ends and where the host portion begins. Once the prefix is known, the mask is not a choice: /24 is 255.255.255.0, /26 is 255.255.255.192, and /20 is 255.255.240.0.

This page is built as a reference first. Use the chart when you need an answer quickly; use the worked methods below when you need to verify a boundary by hand. For the broader design context, see the IPv4 Subnetting Guide. If the slash notation itself is the part you want to understand, start with CIDR Notation Explained.

Figure — How /26 becomes 255.255.255.192

11111111

255mask octet 1

11111111

255mask octet 2

11111111

255mask octet 3

11000000

192mask octet 4

26 network bits 6 host bits

Complete IPv4 subnet mask cheat sheet

The table below includes every valid IPv4 prefix from /0 through /32. “Traditional usable hosts” is the classic subnetting count for /0 through /30: total addresses minus the network and broadcast endpoints. It is arithmetic, not a claim that every address in a very large block is globally assignable. /31 and /32 use different operational semantics and are marked separately.

CIDR Subnet mask Wildcard Total addresses Traditional usable hosts
/0 0.0.0.0 255.255.255.255 4,294,967,296 4,294,967,294
/1 128.0.0.0 127.255.255.255 2,147,483,648 2,147,483,646
/2 192.0.0.0 63.255.255.255 1,073,741,824 1,073,741,822
/3 224.0.0.0 31.255.255.255 536,870,912 536,870,910
/4 240.0.0.0 15.255.255.255 268,435,456 268,435,454
/5 248.0.0.0 7.255.255.255 134,217,728 134,217,726
/6 252.0.0.0 3.255.255.255 67,108,864 67,108,862
/7 254.0.0.0 1.255.255.255 33,554,432 33,554,430
/8 255.0.0.0 0.255.255.255 16,777,216 16,777,214
/9 255.128.0.0 0.127.255.255 8,388,608 8,388,606
/10 255.192.0.0 0.63.255.255 4,194,304 4,194,302
/11 255.224.0.0 0.31.255.255 2,097,152 2,097,150
/12 255.240.0.0 0.15.255.255 1,048,576 1,048,574
/13 255.248.0.0 0.7.255.255 524,288 524,286
/14 255.252.0.0 0.3.255.255 262,144 262,142
/15 255.254.0.0 0.1.255.255 131,072 131,070
/16 255.255.0.0 0.0.255.255 65,536 65,534
/17 255.255.128.0 0.0.127.255 32,768 32,766
/18 255.255.192.0 0.0.63.255 16,384 16,382
/19 255.255.224.0 0.0.31.255 8,192 8,190
/20 255.255.240.0 0.0.15.255 4,096 4,094
/21 255.255.248.0 0.0.7.255 2,048 2,046
/22 255.255.252.0 0.0.3.255 1,024 1,022
/23 255.255.254.0 0.0.1.255 512 510
/24 255.255.255.0 0.0.0.255 256 254
/25 255.255.255.128 0.0.0.127 128 126
/26 255.255.255.192 0.0.0.63 64 62
/27 255.255.255.224 0.0.0.31 32 30
/28 255.255.255.240 0.0.0.15 16 14
/29 255.255.255.248 0.0.0.7 8 6
/30 255.255.255.252 0.0.0.3 4 2
/31 255.255.255.254 0.0.0.1 2 2 endpoints*
/32 255.255.255.255 0.0.0.0 1 1 address*

Do not force the subtract-two rule: for a conventional subnet through /30, the first address is the network address and the last is the broadcast address. A /31 is commonly used as a two-endpoint point-to-point subnet under RFC 3021, where those conventional reservations do not apply. A /32 identifies one address, commonly as a host route or loopback address.

The only subnet-mask octet values you need to recognize

A valid IPv4 subnet mask is contiguous: all the 1 bits come first, then all the 0 bits. That leaves only nine possible values for an octet that contains the boundary. Memorizing those values is more useful than memorizing dozens of complete masks.

Figure — Valid partial-octet mask values come from contiguous 1 bits, never from arbitrary decimal values

0 bits000000000
1 bit12810000000
2 bits19211000000
3 bits22411100000
4 bits24011110000
5 bits24811111000
6 bits25211111100
7 bits25411111110
8 bits25511111111

This is also a fast validation check. 255.255.255.192 is valid because 192 is 11000000. A mask such as 255.255.255.200 is not valid: 200 is 11001000, which turns 1 bits back on after zeros have already appeared.

The block-size shortcut

When the mask boundary falls inside an octet, subtract the mask value in that octet from 256. The result is the block size, sometimes called the increment or “magic number.” Network boundaries occur at multiples of that number in the same octet.

block size = 256 - mask value in the boundary octet
/26 -> 255.255.255.192 -> 256 - 192 = 64
/20 -> 255.255.240.0   -> 256 - 240 = 16
/23 -> 255.255.254.0   -> 256 - 254 = 2

The phrase “boundary octet” matters. For /26 it is the fourth octet. For /20 and /23 it is the third. The block size is applied where the mask changes from full 255 octets toward host space, not blindly to the final octet of the IP address.

Worked example: 192.168.10.77/26

A /26 corresponds to 255.255.255.192. The boundary octet is the fourth octet, and its block size is 64. The fourth-octet network boundaries are therefore 0, 64, 128, and 192. The value 77 falls inside the 64–127 block.

Figure — The host 192.168.10.77 falls in the /26 block that starts at 192.168.10.64

0–63
64–127contains .77
128–191
192–255
IP address:       192.168.10.77/26
Subnet mask:      255.255.255.192
Network:          192.168.10.64
Broadcast:        192.168.10.127
Usable range:     192.168.10.65 - 192.168.10.126
Total addresses:  64
Usable hosts:     62

If you prefer binary verification, the last octet of 77 is 01001101. AND it with the mask octet 11000000 and the result is 01000000, which is 64. The shortcut and the bitwise operation arrive at the same network address.

Worked example: 10.34.77.201/20

A /20 mask is 255.255.240.0, so the boundary sits in the third octet. The block size is 16. Third-octet boundaries are 0, 16, 32, 48, 64, 80, and so on, continuing in increments of 16 through 240–255. The value 77 falls in the 64–79 block, which fixes the network at 10.34.64.0/20.

Figure — With /20, the third octet selects the network block; 77 belongs to the 64–79 interval

0–15
16–31
32–47
48–63
64–79contains .77
80–95
96–111
112–127
…continues through 240–255
IP address:       10.34.77.201/20
Subnet mask:      255.255.240.0
Network:          10.34.64.0
Broadcast:        10.34.79.255
Usable range:     10.34.64.1 - 10.34.79.254
Total addresses:  4,096
Usable hosts:     4,094

Common failure mode: do not take the block size from 240 and then apply it to the fourth octet simply because the host address ends in .201. The mask tells you which octet contains the boundary. Here, that is the third octet.

Choose a prefix from the host requirement

For conventional IPv4 LAN sizing, work from the smallest block that can hold the required hosts. The numbers grow quickly, so a short ladder is often enough for day-to-day work. Capacity and design headroom are separate questions: a subnet that barely fits today may be a poor operational choice if the segment is expected to grow.

Figure — Conventional usable-host capacity from /30 through /24

/30need 22 usable
/29need 66 usable
/28need 1414 usable
/27need 3030 usable
/26need 6262 usable
/25need 126126 usable
/24need 254254 usable

Point-to-point exception: /31 can provide two endpoint addresses where RFC 3021 semantics are supported, independent of this conventional LAN-sizing ladder.

Need at least Prefix Mask Total Conventional usable
2 /30 255.255.255.252 4 2
6 /29 255.255.255.248 8 6
14 /28 255.255.255.240 16 14
30 /27 255.255.255.224 32 30
62 /26 255.255.255.192 64 62
126 /25 255.255.255.128 128 126
254 /24 255.255.255.0 256 254
510 /23 255.255.254.0 512 510
1,022 /22 255.255.252.0 1,024 1,022
2,046 /21 255.255.248.0 2,048 2,046
4,094 /20 255.255.240.0 4,096 4,094

For a full variable-length allocation plan, use the VLSM Calculator. For a single address and prefix, the Subnet Calculator is faster than doing the arithmetic by hand.

Subnet mask, CIDR prefix, and wildcard mask are related, but not interchangeable

A CIDR prefix and a subnet mask describe the same network/host boundary in different notation. A wildcard mask is the bitwise inverse of the subnet mask and is used by some routing, ACL, and policy syntaxes. It does not redefine the subnet.

Representation Example What it expresses
CIDR prefix /26 Counts 26 network bits
Subnet mask 255.255.255.192 1 bits mark the fixed prefix
Wildcard mask 0.0.0.63 Inverse of the subnet mask
subnet mask octet + wildcard octet = 255
192 + 63 = 255
240 + 15 = 255
254 + 1 = 255

Wildcard masks matter in certain configuration languages, but they should not be used as a substitute for understanding the actual CIDR boundary. When you are documenting a network, the prefix is usually the clearest compact form.

/31 and /32 are not mistakes

/31: two addresses for a point-to-point link

A /31 contains two addresses. Under RFC 3021 semantics, both can be used as endpoints on a point-to-point link because there is no need for the conventional network and directed-broadcast endpoints inside that two-address block. Support depends on the platform and the interface context, so treat /31 as an intentional point-to-point design choice, not as a general LAN host-count shortcut.

/32: one address

A /32 fixes all 32 IPv4 bits. It therefore identifies exactly one address. You will commonly see /32s used for loopbacks, host routes, tunnel endpoints, and policy objects. The “total minus two” rule does not apply because a /32 is not being used as a conventional multi-host broadcast subnet.

How to spot an invalid subnet mask

A dotted-decimal mask is valid only when its binary form is a single uninterrupted run of 1s from the left, followed by 0s. Once a zero appears, no later bit may be 1. That gives you two quick checks: each octet must be one of the valid values, and the octets must progress from 255s to at most one partial octet and then to zeros — mask continuity across the complete 32-bit value is what matters, not just whether each octet independently appears in the valid-values list.

Mask Status Reason
255.255.255.0 Valid /24
255.255.255.192 Valid /26
255.255.240.0 Valid /20
255.255.255.200 Invalid 200 = 11001000; bits are not contiguous
255.255.0.255 Invalid 1 bits resume after a zero octet
255.240.255.0 Invalid a full 255 octet appears after a partial octet

Subnet masks in IPv6

IPv6 uses the same prefix-length idea but does not normally write masks in IPv4-style dotted decimal. An IPv6 network is expressed directly with a prefix such as 2001:db8:1234::/48 or 2001:db8:1234:10::/64. The slash still counts fixed bits from the left. If you are planning IPv6 prefixes, use the prefix length rather than trying to invent an IPv6 equivalent of 255.255.255.0. See the IPv6 Subnetting Tools guide for IPv6-specific planning and examples.

Which IPRevealed tool should you use?

Task Recommended tool
I have an IP address and prefix Subnet Calculator
I need to allocate different subnet sizes VLSM Calculator
I need to divide one network into smaller prefixes Subnet Splitter
I need CIDR – start/end range conversion CIDR & IP Range Converter
I need to check whether two ranges collide Subnet Overlap Checker
I need to aggregate adjacent routes Route Summarization Calculator

Common subnet-mask mistakes worth checking

  • Using the host address itself as if it were a network boundary. 192.168.10.77/26 belongs to 192.168.10.64/26; it is not a /26 network ID.
  • Applying the block size to the wrong octet. The mask, not the visual shape of the IP address, tells you where the boundary sits.
  • Treating every small prefix with the same host formula. /31 and /32 have deliberate operational uses that do not fit the old subtract-two shortcut.
  • Assuming a valid-looking decimal number is a valid mask octet. Mask bits must be contiguous from the left.
  • Sizing only for today. The smallest mathematically valid prefix is not automatically the best operational allocation if the segment is likely to grow.
  • Confusing a wildcard mask with a subnet mask. They are inverses used for different purposes.

FAQ

What subnet mask is /24?

/24 is 255.255.255.0. It contains 256 total IPv4 addresses and, in a conventional broadcast subnet, 254 usable host addresses.

What subnet mask is /26?

/26 is 255.255.255.192. It creates blocks of 64 addresses in the fourth octet and provides 62 conventional usable host addresses per subnet.

What subnet mask gives 30 usable hosts?

A /27, or 255.255.255.224, contains 32 total addresses and 30 conventional usable host addresses.

How do I convert a subnet mask to CIDR?

Count the contiguous 1 bits in the mask from the left. 255.255.255.192 is 24 full network bits in the first three octets plus two more in the final octet, so the prefix is /26. If the mask is not contiguous, it is not a valid standard IPv4 subnet mask.

Why is the block size 256 minus the mask octet?

An IPv4 octet has 256 possible values, from 0 through 255. In the octet where the network/host boundary falls, subtracting the mask value from 256 gives the number of address values covered before the next network boundary.

Should I use /30 or /31 for a point-to-point link?

A /31 is more address-efficient where both endpoints and the platform support RFC 3021 semantics. /30 remains valid and may still be required by older equipment, operational policy, or a platform that does not support /31 in that context.

The field check: mask, boundary, capacity

When a subnet looks wrong, reduce it to three checks. First, convert the prefix to the correct contiguous mask. Second, find the block size in the boundary octet and verify that the network address sits on a real multiple of that block. Third, confirm that the address count and host-capacity assumptions match how the subnet will actually be used. Those checks catch most hand-calculation errors before they become configuration errors.

RFC 4632 defines CIDR and the modern prefix model; RFC 3021 defines the /31 point-to-point exception. Both are worth knowing by number when a mask needs defending in a design review.