Subnetting Cheat Sheet: CIDR, Masks and Block Sizes
Subnetting cheat sheet with a full CIDR and subnet mask table, block sizes, worked examples, VLSM and private ranges for Network+ and A+.
By CompCertQuiz Editorial · Published · Last reviewed · 8 min read
Part of the Network+ N10-009 study hub: CompTIA Network+ Study Guide (N10-009): 5 Domains
Subnetting is easier with a reference in front of you. This subnetting cheat sheet has the CIDR table (prefix, subnet mask, wildcard mask and host counts), the block-size method for doing it by hand, worked examples, the private and special address ranges and a VLSM example. Two formulas cover most problems: usable hosts = 2(32 - prefix) - 2, and block size = 256 - the mask value in the interesting octet.
CIDR cheat sheet: prefix, subnet mask and hosts
This is the subnet mask cheat sheet for every prefix from /8 to /32. A /31 has two usable addresses on point-to-point links (RFC 3021) and a /32 is a single host.
| Prefix | 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 |
| /32 | 255.255.255.255 | 0.0.0.0 | 1 | 1 |
You do not need to memorize all 25 rows. Learn the last-octet masks below and the powers of two, and you can rebuild any row in seconds.
The last-octet masks to memorize
Most exam problems land in the fourth octet, where the mask values are 128, 192, 224, 240, 248 and 252. The block size is the distance between subnets, and it equals 256 minus the mask value.
| Prefix | Mask in the last octet | Block size | Usable hosts |
|---|---|---|---|
| /25 | 128 | 128 | 126 |
| /26 | 192 | 64 | 62 |
| /27 | 224 | 32 | 30 |
| /28 | 240 | 16 | 14 |
| /29 | 248 | 8 | 6 |
| /30 | 252 | 4 | 2 |
Powers of two
| Host bits | 2 to the power | Total addresses | Usable hosts |
|---|---|---|---|
| 1 | 2^1 | 2 | 2 (/31 only) |
| 2 | 2^2 | 4 | 2 |
| 3 | 2^3 | 8 | 6 |
| 4 | 2^4 | 16 | 14 |
| 5 | 2^5 | 32 | 30 |
| 6 | 2^6 | 64 | 62 |
| 7 | 2^7 | 128 | 126 |
| 8 | 2^8 | 256 | 254 |
| 9 | 2^9 | 512 | 510 |
| 10 | 2^10 | 1024 | 1022 |
Host bits = 32 minus the prefix. A /26 leaves 6 host bits, so there are 26 = 64 addresses and 62 usable hosts.
The block-size method, step by step
- Convert the prefix to a mask. A /26 is 255.255.255.192.
- Find the interesting octet: the one where the mask is not 255 or 0. For /26 it is the fourth octet (192).
- Block size = 256 minus the mask value. 256 - 192 = 64.
- List the subnet boundaries in that octet: 0, 64, 128, 192.
- Find the boundary at or below the address. That is the network address. The next boundary minus 1 is the last address (the broadcast address).
- First usable host = network address + 1. Last usable host = broadcast address - 1.
Worked examples
192.168.10.77/26
| Item | Value |
|---|---|
| Subnet mask | 255.255.255.192 |
| Network address | 192.168.10.64 |
| First usable host | 192.168.10.65 |
| Last usable host | 192.168.10.126 |
| Broadcast address | 192.168.10.127 |
| Usable hosts | 62 |
172.20.45.9/20
| Item | Value |
|---|---|
| Subnet mask | 255.255.240.0 |
| Network address | 172.20.32.0 |
| First usable host | 172.20.32.1 |
| Last usable host | 172.20.47.254 |
| Broadcast address | 172.20.47.255 |
| Usable hosts | 4,094 |
10.200.3.4/9
| Item | Value |
|---|---|
| Subnet mask | 255.128.0.0 |
| Network address | 10.128.0.0 |
| First usable host | 10.128.0.1 |
| Last usable host | 10.255.255.254 |
| Broadcast address | 10.255.255.255 |
| Usable hosts | 8,388,606 |
Check your own answers against these with the free subnet calculator, and drill with unlimited random problems in the subnetting practice tool.
VLSM example: four subnets from one /24
Variable length subnet masks (VLSM) let you give each subnet only the size it needs. Sort the requirements from largest to smallest, give each the smallest subnet that fits, and place them one after another. Here is 192.168.1.0/24 split for 100, 50, 25 and 10 hosts:
| Needs | Subnet | Mask | Usable hosts | Broadcast |
|---|---|---|---|---|
| 100 hosts | 192.168.1.0/25 | 255.255.255.128 | 126 | 192.168.1.127 |
| 50 hosts | 192.168.1.128/26 | 255.255.255.192 | 62 | 192.168.1.191 |
| 25 hosts | 192.168.1.192/27 | 255.255.255.224 | 30 | 192.168.1.223 |
| 10 hosts | 192.168.1.224/28 | 255.255.255.240 | 14 | 192.168.1.239 |
The four subnets use 192.168.1.0 through 192.168.1.239, leaving 192.168.1.240 to 192.168.1.255 free for growth. VLSM and CIDR are both listed under Network+ objective 1.7, see the Network+ N10-009 study guide.
Private and special IPv4 ranges
| Range | Purpose | Reference |
|---|---|---|
| 10.0.0.0/8 | Private (Class A size) | RFC 1918 |
| 172.16.0.0/12 | Private (172.16.0.0 to 172.31.255.255) | RFC 1918 |
| 192.168.0.0/16 | Private (Class C size blocks) | RFC 1918 |
| 169.254.0.0/16 | APIPA / link-local, self-assigned when DHCP fails | RFC 3927 |
| 127.0.0.0/8 | Loopback (127.0.0.1 is localhost) | RFC 1122 |
| 100.64.0.0/10 | Shared address space for carrier-grade NAT | RFC 6598 |
| 224.0.0.0/4 | Multicast | RFC 5771 |
| 0.0.0.0/0 | Default route, matches every address | n/a |
Read the details in RFC 1918, RFC 3927 and RFC 6598.
IPv4 address classes
Classful addressing is no longer used for routing, but Network+ still lists the five classes, so know the first-octet ranges.
| Class | First octet | Default mask | Use |
|---|---|---|---|
| A | 1 to 126 | 255.0.0.0 (/8) | Very large networks |
| B | 128 to 191 | 255.255.0.0 (/16) | Medium networks |
| C | 192 to 223 | 255.255.255.0 (/24) | Small networks |
| D | 224 to 239 | n/a | Multicast |
| E | 240 to 255 | n/a | Reserved |
The 127.x.x.x range is reserved for loopback and sits between Class A and Class B.
Common subnetting mistakes
- Forgetting to subtract 2. The network and broadcast addresses are not usable hosts. A /24 has 254 usable hosts, not 256.
- Using the wrong octet. A /20 puts the interesting octet in the third octet (mask 240), not the fourth. Find the octet first.
- Mixing up the block size and the mask. For /26 the mask value is 192 and the block size is 64. Subnets start at multiples of 64, not 192.
- Picking a subnet that is too small. Count hosts needed plus 2, then round up to the next power of two. Needing 30 hosts means a /27 (30 usable) at the tightest, and needing 31 means a /26.
- Treating a /30 and a /31 alike. A /30 has two usable hosts and a network and broadcast address. A /31 uses both addresses on a point-to-point link.
Practice and next steps
- Do 10 problems a day in the subnetting practice tool at beginner level until you are fast, then move to intermediate and advanced.
- Check your work with the subnet calculator.
- Learn the ports next with the Network+ ports and protocols cheat sheet.
- Test yourself on realistic questions: Network+ N10-009 practice questions (40 free) or the free A+ Core 1 practice test.
Frequently asked questions
How do I calculate usable hosts?
Raise 2 to the number of host bits (32 minus the prefix) and subtract 2. A /27 has 5 host bits, so 2^5 - 2 = 30 usable hosts.
What is the wildcard mask?
The inverse of the subnet mask. Subtract each mask octet from 255. The wildcard for 255.255.255.192 is 0.0.0.63. Cisco access lists and OSPF network statements use it.
What is a subnet mask cheat sheet used for?
It lets you look up the mask, block size and host count for a prefix without converting to binary each time, which saves time on Network+ and A+ questions.
Is subnetting on the Network+ exam?
Yes. Network+ N10-009 objective 1.7 covers IPv4 addressing, including subnetting, VLSM, CIDR and address classes.
CompCertQuiz is an independent practice-exam site and is not affiliated with, endorsed by, or sponsored by CompTIA. Our practice questions are original material written for exam preparation. CompTIA and its certification names are trademarks of CompTIA, Inc. Always confirm exam details on comptia.org.