Subnet mask cheat sheet with a /8 to /32 CIDR table: dotted and wildcard masks, host counts, worked examples, /31 and /32 edge cases, common mistakes.
A subnet mask is a 32-bit value whose one-bits mark the network part of an IPv4 address and whose zero-bits mark the host part. This subnet mask cheat sheet gives you the whole /8 to /32 CIDR table in one place. The rule behind it: a /N prefix means the first N bits are the network, and the block holds 2^(32-N) addresses. Subtract two for the network and broadcast addresses to get usable hosts, except on /31 and /32. If you only need one answer, drop an address into the subnet calculator. If you want to understand the answer, read on.
What a subnet mask does
RFC 950 (August 1985) specified the address mask as the way a host learns where the network ends. It describes the mask as a bit-mask with bits set in the fields for the IP network number, plus extra bits for the subnet number field.[1] RFC 4632 later wrote the same idea as a prefix: a 4-octet address, a slash, and a decimal value between 0 and 32 that counts the significant bits.[2] Its example: 172.16.0.0/16 means the mask has 16 one-bits followed by 16 zero-bits, which is 255.255.0.0.[2]
So /24 and 255.255.255.0 are the same fact written two ways. CIDR notation is the shorter way to write it.
The CIDR table: /8 to /32
Bookmark this one. The address counts for each prefix match the table in RFC 4632;[2] the dotted and wildcard masks and the usable-host column are computed from the prefix with Python's ipaddress module. The wildcard mask is simply the mask with every bit flipped.
| CIDR | Subnet mask | Wildcard mask | Total addresses | Usable hosts |
|---|---|---|---|---|
| /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 on point-to-point links[4] |
| /32 | 255.255.255.255 | 0.0.0.0 | 1 | 1 (a host route)[2] |
The pattern is worth memorizing, because it replaces the table. In the interesting octet, the mask value is 256 minus the block size: a /26 has blocks of 64, so the last octet is 256 - 64 = 192. Block starts are multiples of the block size, so /26 networks start at .0, .64, .128 and .192. RFC 4632 says the same thing in its own words: prefixes describe any power-of-two-sized block of addresses.[2] It also notes that, as of its 2006 text, prefixes shorter than /8 had not been allocated or assigned.[2] This table starts at /8 for that reason.
Worked example 1: network, broadcast and host range
Take 192.168.10.77 with mask 255.255.255.192 (/26). The mask has 26 one-bits, so the network address is the IP with the 6 host bits zeroed. Write both in binary and AND them:
192.168.10.77 11000000.10101000.00001010.01001101
255.255.255.192 11111111.11111111.11111111.11000000
AND result 11000000.10101000.00001010.01000000 = 192.168.10.64Last octet: 77 AND 192 = 64. The block size is 64, so the broadcast address is the last address before the next block, 64 + 63 = 127. I checked every value below with Python's ipaddress module:
| Item | Value |
|---|---|
| Network address | 192.168.10.64 |
| Broadcast address | 192.168.10.127 |
| First usable host | 192.168.10.65 |
| Last usable host | 192.168.10.126 |
| Usable hosts | 62 |
Why two addresses are lost: on an ordinary subnet the all-zeros host value names the network and the all-ones value is the broadcast. RFC 3021 states this directly when it explains the /30: four addresses per link, which means two host addresses, one all-zeros network and one all-ones broadcast.[4] The usable-hosts column subtracts those same two addresses for every prefix from /8 through /30.
Skip the binary for a one-off check and use the subnet calculator with 192.168.10.77/26. It should return the same five values.
Worked example 2: split a /24 into four subnets
Four subnets need 2 extra bits (2^2 = 4), so 24 + 2 = /26. Each block holds 64 addresses. Python confirms the split of 192.168.10.0/24:
import ipaddress
for s in ipaddress.ip_network('192.168.10.0/24').subnets(new_prefix=26):
hosts = list(s.hosts())
print(s, hosts[0], hosts[-1], s.broadcast_address)The output, reformatted as a table:
| Subnet | Usable range | Broadcast |
|---|---|---|
| 192.168.10.0/26 | 192.168.10.1 to 192.168.10.62 | 192.168.10.63 |
| 192.168.10.64/26 | 192.168.10.65 to 192.168.10.126 | 192.168.10.127 |
| 192.168.10.128/26 | 192.168.10.129 to 192.168.10.190 | 192.168.10.191 |
| 192.168.10.192/26 | 192.168.10.193 to 192.168.10.254 | 192.168.10.255 |
Splitting costs hosts. One /24 gave 254 usable addresses; four /26 subnets give 4 x 62 = 248. The six missing addresses are the extra network and broadcast pairs. Splitting the same /24 into eight /27 subnets leaves 8 x 30 = 240.
A 1985 caveat on this split. RFC 950 says the values of all zeros and all ones in the subnet field should not be assigned to actual subnets; in its 6-bit example, the subnet field may have any value except 0 and 63.[1] By that original rule, the first and last /26 above (192.168.10.0/26 and 192.168.10.192/26) would be off limits. This post does not cover whether later standards relax that rule, so treat it as unverified here. Check the documentation of your router or cloud provider before you use the first and last subnet of a split.
Worked example 3: how the AND decides local vs gateway
RFC 950 describes the test every host runs before it sends a packet. If the destination ANDed with the host's own mask equals the host's own address ANDed with the same mask, the datagram goes directly to the destination on the local network. Otherwise it goes to a gateway.[1] The RFC's version, as pseudocode:
IF bitwise_and(dg.ip_dest, my_ip_mask)
= bitwise_and(my_ip_addr, my_ip_mask)
THEN
send_dg_locally(dg, dg.ip_dest)
ELSE
send_dg_locally(dg,
gateway_to(bitwise_and(dg.ip_dest, my_ip_mask)))Run that test for a host at 10.1.1.20 with mask 255.255.255.0. I ran the AND check in Python for these cases:
| Destination | Mask on the host | Same network? | Packet goes to |
|---|---|---|---|
| 10.1.1.200 | 255.255.255.0 | Yes | The destination directly |
| 10.1.2.5 | 255.255.255.0 | No | The default gateway |
| 10.1.2.5 | 255.255.254.0 | No | The default gateway |
The mask on the sending host alone decides the answer. Nothing asks the destination what it thinks its mask is. That one-sided decision is why a wrong mask on a single machine causes the strange, half-working failures in the mistakes table below.
Edge cases: /31, /32 and special addresses
/31 on point-to-point links. A /31 has one host bit, so only two addresses exist: the all-zeros and all-ones host values. RFC 3021 (December 2000) says that on a point-to-point link with a 31-bit mask, these two addresses MUST be interpreted as host addresses.[4] The saving is real: each link uses two addresses instead of four, so 500 links save 1,000 addresses.[4] There is no directed broadcast on such a link, and the limited broadcast must be used for broadcast traffic.[4] The catch: RFC 3021 warns that a point-to-point link where only one end supports 31-bit prefixes may not operate correctly.[4] Configure both ends or neither. Python agrees with the RFC on the arithmetic: 10.0.0.0/31 contains 10.0.0.0 and 10.0.0.1, and both come back as hosts.
/32 host route. All 32 bits are network, so the prefix names one address. RFC 4632 labels n.n.n.n/32 a "host route".[2]
/0 default route. The other end of the scale. RFC 4632 lists 0.0.0.0/0 as the "default route", a block of 4,294,967,296 addresses, which is the entire IPv4 space.[2]
Private ranges. RFC 1918 (February 1996) reserves three blocks for private internets:[3]
| Block | Range | Prefix | Addresses |
|---|---|---|---|
| 10.0.0.0 | 10.0.0.0 to 10.255.255.255 | 10/8 | 16,777,216 |
| 172.16.0.0 | 172.16.0.0 to 172.31.255.255 | 172.16/12 | 1,048,576 |
| 192.168.0.0 | 192.168.0.0 to 192.168.255.255 | 192.168/16 | 65,536 |
The address counts are computed. The middle row trips people up: 172.16.0.0/12 runs through 172.31.255.255, so 172.32.x.x is not private. RFC 1918 also says that packets with private source or destination addresses should not be forwarded across inter-enterprise links, and that ISPs are expected to filter routing information about private networks.[3] It recommends that an organization using private addresses choose randomly from the reserved pool when allocating internal sub-blocks, to reduce the risk of a clash if two organizations later connect.[3] If every office picks 192.168.0.0/24 or 192.168.1.0/24, a future VPN between them collides on day one.
What breaks: common subnet mask mistakes
| Mistake | What you see | Why | Fix |
|---|---|---|---|
| Wrong mask on one host | Host reaches some neighbors but not others | A host at 192.168.1.10 set to /24 on a /25 network treats 192.168.1.130 as local (the AND matches), while the real network puts that address behind the router. With the correct /25 mask the same test says "not local". I checked both results with a script. | Compare the mask on every host and on the router interface; they must all agree |
| Non-contiguous mask | Hard-to-read subnets; a script refused to parse it | RFC 950 allowed masks with non-adjacent bits and gave 255.255.255.88 (01011000) as an example, but recommends the subnet bits be contiguous.[1] Python's ipaddress module refused to parse that mask as a network. | Use contiguous masks only; stick to the table above |
| Off-by-one on usable hosts | The plan promises 64 hosts per /26 and the 63rd device has no address | A /26 has 64 addresses but 62 usable hosts; the first is the network and the last is the broadcast | Use 2^(32-N) - 2, and size up when you plan for growth |
| Assigning the network or broadcast address to a host | The address is reserved for the subnet itself, not for a device | For 192.168.10.64/26 those are .64 and .127 | Stay inside the first-to-last usable range |
| Wrong base for a block | "192.168.10.100/26" entered as a network ID | A /26 network must start on a multiple of 64; .100 is inside the .64 block | Round down to the block start: 192.168.10.64/26 |
| /31 on one end of a link | The link may not operate correctly | RFC 3021 notes that a point-to-point link with only one end supporting /31 may not operate correctly[4] | Match the prefix length on both ends |
| Reading 172.16.0.0/12 as 172.16.x.x only | Overlap with 172.20.x.x or 172.31.x.x networks you thought were public | The /12 block covers 172.16.0.0 to 172.31.255.255[3] | Treat the whole 16-network span as private space |
| Host bits set in a CIDR block | Tool reports "has host bits set" or silently rewrites it | 172.20.5.9/12 is not a network address; the network is 172.16.0.0/12, as Python confirmed | Zero the host bits before you write a route or ACL |
Quick reference
A /N prefix keeps N bits for the network and leaves 32-N for hosts. Total addresses are 2^(32-N); usable hosts are that minus 2, except /31 (2, for point-to-point links under RFC 3021) and /32 (a single host route). The mask octet in the active byte is 256 minus the block size, and blocks start at multiples of their size. A host decides local versus gateway by ANDing the destination and its own address with its own mask and comparing. Private space is 10/8, 172.16/12 and 192.168/16. When you need numbers for a specific address, use a subnet calculator and check the result against the table above.
Sources
- RFC 950: Internet Standard Subnetting Procedure, J. Mogul and J. Postel, August 1985 (accessed November 26, 2026)
- RFC 4632: Classless Inter-domain Routing (CIDR): The Internet Address Assignment and Aggregation Plan, BCP 122, IETF, August 2006 (accessed November 26, 2026)
- RFC 1918: Address Allocation for Private Internets, BCP 5, IETF, February 1996 (accessed November 26, 2026)
- RFC 3021: Using 31-Bit Prefixes on IPv4 Point-to-Point Links, IETF, December 2000 (accessed November 26, 2026)
Written by
WOWHOW
The WOWHOW team brings 14+ years of production engineering experience. Every tool and product in the catalog is built, tested, and curated in-house.
Monday memo · free
One insight, every Monday. 7am IST.
1 field report, 3 links, 1 tool we actually use. No fluff, no spam.
Beyond the writing
Need production-ready templates?
Free browser tools with no signup, plus premium dev templates and starter kits.
Comments · 0
Beta: comments are stored locally on your device and not visible to other readers.
No comments yet. Be the first to share your thoughts.