The CCNA exam (200-301) gives you about 90 seconds per question and roughly 8-12 subnetting questions per exam. If you have to do long-form binary arithmetic for each one, you will run out of time. The good news: every CCNA subnetting question fits one of about eight patterns, and each pattern has a 30-second mental solution.
This article walks through all eight, with the shortest method for each. If you commit these patterns to muscle memory, subnetting questions become free points on the exam.
The two foundations you need
Memorize these two things and the rest follows.
1. Powers of 2 up to 256
| n | 2^n | n | 2^n |
|---|---|---|---|
| 1 | 2 | 5 | 32 |
| 2 | 4 | 6 | 64 |
| 3 | 8 | 7 | 128 |
| 4 | 16 | 8 | 256 |
You will use these to compute subnet sizes, host counts, and address counts. Burn them into memory.
2. The magic number method
The "magic number" is the increment between consecutive subnets in the interesting octet. To find it:
- Identify the interesting octet — the one where the mask transitions from 255 to a smaller value.
- Compute the magic number: 256 − mask value in that octet.
- Subnets begin at multiples of the magic number in that octet.
Examples:
/27= mask255.255.255.224. Interesting octet is the 4th, magic number = 256 − 224 = 32. Subnets at .0, .32, .64, .96, .128, .160, .192, .224./20= mask255.255.240.0. Interesting octet is the 3rd, magic number = 256 − 240 = 16. Subnets at .0, .16, .32, .48.../22= mask255.255.252.0. Interesting octet is the 3rd, magic number = 256 − 252 = 4. Subnets at .0, .4, .8, .12...
Pattern 1: "What is the subnet of host X?"
Example: What subnet does host 192.168.1.130 with mask 255.255.255.192 belong to?
Method: Find the magic number (256 − 192 = 64). Find the largest multiple of 64 that is ≤ 130 (it's 128). The subnet is 192.168.1.128/26.
Why this works: Subnets start at multiples of the magic number. The host belongs to whichever subnet has the largest starting address less than or equal to the host's address.
Pattern 2: "What is the broadcast address of host X?"
Example: What is the broadcast address for host 10.0.5.42/22?
Method: First find the subnet using Pattern 1. The mask /22 has magic number 4 in the third octet. Largest multiple of 4 ≤ 5 is 4. Subnet is 10.0.4.0/22. Add (magic number − 1) to that octet and 255 to all the following octets: broadcast is 10.0.7.255.
Pattern 3: "How many usable hosts in /X?"
Example: How many usable hosts in a /26?
Method: Usable = 2^(32−prefix) − 2. For /26: 2^6 − 2 = 64 − 2 = 62.
Exception: /31 has 2 usable (RFC 3021). /32 has 1 (the address itself).
Common answers to memorize:
| Prefix | Usable hosts |
|---|---|
| /30 | 2 |
| /29 | 6 |
| /28 | 14 |
| /27 | 30 |
| /26 | 62 |
| /25 | 126 |
| /24 | 254 |
| /23 | 510 |
| /22 | 1,022 |
Pattern 4: "What prefix gives me N hosts?"
Example: You need 50 hosts. What prefix?
Method: Round 50 up to the next power of 2 (= 64). Add 2 for network/broadcast (66). Wait — we round up before adding, because 64 ≥ 50 only if we count the 2 reserved. The formula:
- You need N hosts.
- You need at least N + 2 total addresses (for network + broadcast).
- Round up to next power of 2.
- Prefix = 32 − log₂(that power).
For N=50: 50 + 2 = 52 → next power of 2 is 64 → 2^6 = 64 → prefix = 32 − 6 = /26 (62 usable). Done.
Pattern 5: "Convert subnet mask to prefix"
Example: What is the prefix for mask 255.255.240.0?
Method: The mask has 16 "255" bits (first two octets) plus the leading 1s in the third octet. 240 in binary is 11110000 — four 1s. So prefix = 16 + 4 = /20.
Memorize the third/fourth octet values:
| Octet value | Leading 1s |
|---|---|
| 0 | 0 |
| 128 | 1 |
| 192 | 2 |
| 224 | 3 |
| 240 | 4 |
| 248 | 5 |
| 252 | 6 |
| 254 | 7 |
| 255 | 8 |
Pattern 6: "Which addresses are valid hosts?"
Example: Which of these is a valid host on 172.16.32.0/20?
- A) 172.16.32.0
- B) 172.16.47.255
- C) 172.16.48.0
- D) 172.16.42.100
Method: /20 has magic number 16 in the third octet. Subnet is 32-47 in the third octet. Network = 172.16.32.0, broadcast = 172.16.47.255. So A is network, B is broadcast, C is outside the subnet, D is a valid host.
Answer: D.
Pattern 7: "How many subnets in a /X if I borrow N bits?"
Example: If you have a /24 and subnet it into /27s, how many subnets do you get?
Method: Borrowed bits = 27 − 24 = 3. Subnet count = 2^3 = 8.
Each /27 has 30 usable hosts (Pattern 3). 8 subnets × 30 hosts = 240 total addressable, vs 254 in the unsubnetted /24. The "loss" of 14 addresses is the subnetting tax: 7 extra subnets times 2 reserved addresses each.
Pattern 8: VLSM allocation
Example: Given 10.0.0.0/24, allocate subnets for groups of 60, 30, 14, and 6 hosts.
Method: Always allocate largest first.
- 60 hosts → /26 → starts at 10.0.0.0, covers .0–.63
- 30 hosts → /27 → starts at 10.0.0.64, covers .64–.95
- 14 hosts → /28 → starts at 10.0.0.96, covers .96–.111
- 6 hosts → /29 → starts at 10.0.0.112, covers .112–.119
- Remaining: 10.0.0.120 to 10.0.0.255 (136 addresses) free for future
See our full VLSM article for more worked examples and the gotchas around alignment.
Practice strategy for the exam
- Drill flashcards of the prefix-to-hosts table and the octet-to-bits table. These should be automatic recall, not calculation.
- Practice the magic number method until you can do it without writing anything down.
- For VLSM questions, always allocate largest first. Always.
- If the question gives you a host address and asks for the subnet, do not try to convert to binary. Use the magic number method.
- Use our Practice Quiz to drill these patterns — it generates questions of every type and tracks your streak.
Key takeaways
- Memorize powers of 2 up to 256 and the mask-to-bits conversion table. These are the foundation.
- The magic number method (256 − mask) answers most exam questions in under 30 seconds.
- The 8 question patterns above cover almost every subnetting question on the CCNA. Drill them until they are automatic.
- Always allocate largest-first for VLSM.