Quick answer
Subnetting splits one IP network into smaller networks by moving the boundary between the network and host bits of a 32-bit IPv4 address. A /N prefix leaves 32 minus N host bits, giving 2 to that power in total addresses and two fewer usable hosts. The block-size shortcut finds network and broadcast addresses in seconds.
Subnetting is not a trick or an obscure skill — it is arithmetic with a fixed, learnable pattern. Once the pattern clicks, subnetting questions go from the scariest part of an exam to the fastest points available, because unlike a scenario question, there is exactly one correct answer and a mechanical way to reach it. This is the single most-tested skill on CompTIA Network+, appears throughout Cisco CCNA, and shows up in a lighter form even on cloud certifications where VPC and subnet sizing decisions matter.
The mental model
An IPv4 address is 32 bits, split conceptually into a network portion and a host portion. The network portion identifies which network an address belongs to; the host portion identifies a specific device on that network. Subnetting means moving the boundary between those two portions — borrowing bits from the host side to create more, smaller networks, at the cost of fewer possible hosts per network. Subnetting lives at Layer 3, so the OSI model explained guide is a useful companion for seeing where addressing fits among the seven layers.
Think of it like a postal address: the network portion is the street, the host portion is the house number. Subnetting is deciding to split one long street into several shorter streets, each with its own name — you gain more distinct streets, but each one has fewer house numbers to hand out.
CIDR notation explained
CIDR (Classless Inter-Domain Routing) notation writes the network-portion length as a number after a slash: 192.168.1.0/24 means the first 24 bits (of 32 total) are the network portion, leaving 8 bits for hosts. This is equivalent to the subnet mask 255.255.255.0 — CIDR notation and dotted-decimal subnet masks describe the exact same boundary, just written differently. The exam expects you to convert fluently between both notations.
| CIDR | Subnet mask | Host bits |
|---|---|---|
| /24 | 255.255.255.0 | 8 |
| /25 | 255.255.255.128 | 7 |
| /26 | 255.255.255.192 | 6 |
| /27 | 255.255.255.224 | 5 |
| /28 | 255.255.255.240 | 4 |
| /29 | 255.255.255.248 | 3 |
| /30 | 255.255.255.252 | 2 |
The formula that solves every question
Three steps, every time:
- Host bits = 32 − CIDR prefix
- Total addresses = 2host bits
- Usable hosts = total addresses − 2 (subtracting the network address and the broadcast address)
That subtract-2 step is where most points are lost on exam day — not because the math is hard, but because it is easy to forget under time pressure, or to apply when the question actually asked for total addresses, not usable hosts. Read the question stem twice before committing to an answer.
Worked example: /26
Network: 192.168.50.0/26
Host bits = 32 − 26 = 6
Total addresses = 26 = 64
Usable hosts = 64 − 2 = 62
Network address: 192.168.50.0
First usable host: 192.168.50.1
Last usable host: 192.168.50.62
Broadcast address: 192.168.50.63
Worked example: /28
Network: 10.0.5.16/28
Host bits = 32 − 28 = 4
Total addresses = 24 = 16
Usable hosts = 16 − 2 = 14
Network address: 10.0.5.16
First usable host: 10.0.5.17
Last usable host: 10.0.5.30
Broadcast address: 10.0.5.31
Notice the pattern: each subnet's size (16 addresses here) is also the “block size” you add to find the next subnet's starting address — the next /28 after 10.0.5.16/28 starts at 10.0.5.32. This block-size shortcut is faster than recalculating from scratch for consecutive subnets.
Network address vs broadcast address
Every subnet reserves exactly two addresses that no host can use: the network address (all host bits set to 0 — identifies the subnet itself, used in routing tables) and the broadcast address (all host bits set to 1 — a single address that reaches every host on that subnet at once). This is why the formula always subtracts 2. The only IPv4 exceptions are /31 (point-to-point links, both addresses usable per RFC 3021, no network/broadcast reserved) and /32 (a single host route, not really a "subnet" in the usual sense).
VLSM — sizing subnets to actual need
Variable Length Subnet Masking (VLSM) means carving different-sized subnets out of the same address block instead of using one fixed size everywhere. Real networks have wildly different host requirements per segment — a server VLAN might need 50 addresses, a point-to-point router link needs exactly 2. VLSM assigns each subnet only as many addresses as it needs, largest to smallest, avoiding the address waste a flat subnet size would cause. The full step-by-step method, with more worked examples, is in our VLSM deep dive.
VLSM example — 192.168.1.0/24, four departments
| Need | Subnet assigned | Usable hosts |
|---|---|---|
| 50 hosts (largest first) | 192.168.1.0/26 | 62 |
| 25 hosts | 192.168.1.64/27 | 30 |
| 10 hosts | 192.168.1.96/28 | 14 |
| 2 hosts (router link) | 192.168.1.112/30 | 2 |
The rule: always allocate largest-need-first. If you assign small subnets first, you can accidentally fragment the address space so the larger subnet you need later no longer fits in one contiguous block. This ordering trap is a common CCNA design-scenario question.
How this differs in IPv6
The concept transfers — borrowing bits to create smaller networks — but the practice looks different. IPv6 has no broadcast address at all (multicast covers that use case), address space is vast enough that conservation is not the driving concern it is in IPv4, and the common real-world convention is allocating uniform /64 subnets rather than VLSM-style variable sizing. Exam questions on IPv6 addressing tend to focus on address typerecognition (global unicast, link-local, unique local) rather than subnetting math. For a side-by-side look at the two address families, see IPv4 vs IPv6.
Common misconceptions
- “Usable hosts and total addresses are the same thing.” False — always subtract 2 unless the question explicitly asks for total addresses in the block.
- “A /24 always means a class C-style network.” False — classful addressing (Class A/B/C) is obsolete. CIDR lets any prefix length apply to any address range.
- “VLSM subnets need to be assigned in address order.” False — they need to be assigned largest-need-first to avoid fragmentation, not in numeric address order.
- “/31 always wastes 2 addresses like every other prefix.” False — /31 is a documented exception for point-to-point links where both addresses are usable.
How to get fast at this
Speed comes from pattern memorization, not re-deriving the formula every time. Memorize the total-addresses column for /24 through /30 (256, 128, 64, 32, 16, 8, 4) so you recognize them instantly. Then practice timed: aim to answer a "given this CIDR, what are the usable hosts and broadcast address" question in under 45 seconds without scratch paper. That speed threshold is what separates comfortable exam pacing from running out of time on the last stretch of questions.
How this is tested across certifications
Subnetting is the connective tissue across nearly every entry-to-associate-level networking and security certification:
- CompTIA Network+ — the single most-tested skill on the exam, reused across Domains 1, 2, 4, and 5. Full breakdown: Network+ Exam Guide.
- Cisco CCNA — tested at similar depth plus VLSM network-design scenarios, since CCNA expects you to design address schemes, not just calculate given ones. See Network+ vs CCNA.
- CompTIA Security+ — tested indirectly through network segmentation and firewall-rule scenario questions that assume you can read CIDR notation fluently. Those rules also depend on knowing which services run over TCP versus UDP, covered in TCP vs UDP Explained.
- Cloud certifications (AWS, Google Cloud, Azure) — a lighter version, sizing VPC and subnet CIDR blocks, though cloud providers reserve additional addresses per subnet beyond the standard network/broadcast pair (AWS reserves 5, for example).
How does a subnet mask actually work in binary?
The shortcuts below all come from one operation: a router (or you, on paper) performs a bitwise AND between the address and the mask. Every bit where the mask is 1 is kept (network portion); every bit where the mask is 0 is zeroed out (host portion). The result is the network address.
Binary walkthrough: 192.168.10.77/26
Mask /26 = 11111111.11111111.11111111.11000000 = 255.255.255.192
Last octet of the address: 77 = 01001101
AND with 11000000: 01001101 AND 11000000 = 01000000 = 64
Network address: 192.168.10.64
Broadcast (host bits all 1): 01111111 = 127, so 192.168.10.127
Usable range: 192.168.10.65 to 192.168.10.126 (62 hosts)
Memorize the bit values of one octet: 128, 64, 32, 16, 8, 4, 2, 1. Any octet value from 0 to 255 is a sum of those eight numbers, and every mask octet is a running total from the left: 128, 192 (128+64), 224, 240, 248, 252, 254, 255. Those eight values are the only ones that can ever appear in a valid subnet mask.
| Bits in octet set to 1 | Mask octet value | Block size (256 minus mask) | Prefix when it is the last octet |
|---|---|---|---|
| 1 | 128 | 128 | /25 |
| 2 | 192 | 64 | /26 |
| 3 | 224 | 32 | /27 |
| 4 | 240 | 16 | /28 |
| 5 | 248 | 8 | /29 |
| 6 | 252 | 4 | /30 |
| 7 | 254 | 2 | /31 |
| 8 | 255 | 1 | /32 |
What is the fastest way to find the network and broadcast address?
The block-size (magic number) method replaces the binary AND with two subtractions and a multiplication table. It is what most people who answer subnetting questions in under 30 seconds are actually doing.
- Find the interesting octet: the one where the mask is neither 255 nor 0.
- Block size = 256 minus the mask value in that octet.
- The network address is the largest multiple of the block size that is less than or equal to the address octet. Octets to the right become 0.
- The broadcast address is the next network address minus 1. Octets to the right become 255.
Worked example: 172.16.45.200/20
Mask = 255.255.240.0, so the interesting octet is the third one (240).
Block size = 256 − 240 = 16.
Multiples of 16 up to 45: 0, 16, 32, 48. The largest that does not exceed 45 is 32.
Network address: 172.16.32.0. Next network: 172.16.48.0.
Broadcast address: 172.16.47.255. Usable range: 172.16.32.1 to 172.16.47.254.
Host bits = 12, so usable hosts = 212 − 2 = 4,094.
Notice that the broadcast address ends in .255 yet the subnet is not a /24. In subnets larger than a /24, addresses ending in .0 or .255 can be perfectly valid host addresses. For example, 10.0.1.255/16 is a legal host because the 16 host bits are not all ones. Exams like to test exactly this.
How many subnets and hosts do I get when I borrow bits?
Every borrowed bit doubles the number of subnets and halves the hosts in each. The subnet count is 2 to the power of borrowed bits; the hosts per subnet is 2 to the power of remaining host bits, minus 2.
| Prefix (from a /24) | Bits borrowed | Subnets | Addresses each | Usable hosts each |
|---|---|---|---|---|
| /25 | 1 | 2 | 128 | 126 |
| /26 | 2 | 4 | 64 | 62 |
| /27 | 3 | 8 | 32 | 30 |
| /28 | 4 | 16 | 16 | 14 |
| /29 | 5 | 32 | 8 | 6 |
| /30 | 6 | 64 | 4 | 2 |
Example: split 192.168.1.0/24 into 8 equal subnets. Eight subnets means 3 borrowed bits (23 = 8), so the new prefix is /27 with a block size of 32.
| Subnet | Network | Usable range | Broadcast |
|---|---|---|---|
| 1 | 192.168.1.0/27 | .1 to .30 | 192.168.1.31 |
| 2 | 192.168.1.32/27 | .33 to .62 | 192.168.1.63 |
| 3 | 192.168.1.64/27 | .65 to .94 | 192.168.1.95 |
| 4 | 192.168.1.96/27 | .97 to .126 | 192.168.1.127 |
| 5 | 192.168.1.128/27 | .129 to .158 | 192.168.1.159 |
| 6 | 192.168.1.160/27 | .161 to .190 | 192.168.1.191 |
| 7 | 192.168.1.192/27 | .193 to .222 | 192.168.1.223 |
| 8 | 192.168.1.224/27 | .225 to .254 | 192.168.1.255 |
Older study material says the first and last subnets are off limits (the "subnet zero" rule). Modern equipment and current exams treat all subnets as usable, so do not discard them unless a question explicitly invokes classful behavior.
Which prefix do I need for a given number of hosts?
Work backwards: find the smallest number of host bits h where 2h − 2 is at least the number of hosts you need, then the prefix is 32 minus h. Always plan for growth, but on an exam answer for the stated number.
| Hosts needed (up to) | Host bits | Prefix | Usable hosts |
|---|---|---|---|
| 2 | 2 | /30 | 2 |
| 6 | 3 | /29 | 6 |
| 14 | 4 | /28 | 14 |
| 30 | 5 | /27 | 30 |
| 62 | 6 | /26 | 62 |
| 126 | 7 | /25 | 126 |
| 254 | 8 | /24 | 254 |
| 510 | 9 | /23 | 510 |
| 1,022 | 10 | /22 | 1,022 |
| 2,046 | 11 | /21 | 2,046 |
| 4,094 | 12 | /20 | 4,094 |
A frequent trap: a requirement of exactly 30 hosts fits a /27 (30 usable), but 31 hosts needs a /26. The device count includes the router interface acting as the default gateway, so a subnet that must hold 30 PCs plus a gateway needs 31 addresses.
How do I do a full VLSM design step by step?
Here is a complete VLSM exercise in the style of a CCNA design question (more variations are in VLSM explained). Given 192.168.20.0/24, address these segments: Sales (100 hosts), Engineering (50), Support (28), Guest Wi-Fi (12), and two router-to-router WAN links (2 each).
- Sort largest to smallest: 100, 50, 28, 12, 2, 2.
- Pick the smallest prefix that fits each: 100 needs /25 (126), 50 needs /26 (62), 28 needs /27 (30), 12 needs /28 (14), each WAN link needs /30 (2).
- Allocate sequentially from the start of the block, each new subnet beginning where the last one ended, and check that every network address is a multiple of its own block size.
| Segment | Subnet | Usable range | Broadcast |
|---|---|---|---|
| Sales (100) | 192.168.20.0/25 | .1 to .126 | 192.168.20.127 |
| Engineering (50) | 192.168.20.128/26 | .129 to .190 | 192.168.20.191 |
| Support (28) | 192.168.20.192/27 | .193 to .222 | 192.168.20.223 |
| Guest (12) | 192.168.20.224/28 | .225 to .238 | 192.168.20.239 |
| WAN link 1 | 192.168.20.240/30 | .241 to .242 | 192.168.20.243 |
| WAN link 2 | 192.168.20.244/30 | .245 to .246 | 192.168.20.247 |
| Unused | 192.168.20.248/29 | .249 to .254 | 192.168.20.255 |
Everything fits with a spare /29 left over. If you allocated small subnets first, a later large subnet would have to start on a multiple of its own block size and you could be forced to skip over the gaps, which is why the largest-first rule exists.
What are wildcard masks and route summarization?
Two subnetting-adjacent skills show up on CCNA. A wildcard mask is the inverse of the subnet mask (255.255.255.255 minus the mask): a /26 mask of 255.255.255.192 becomes 0.0.0.63. Access lists and OSPF network statements use wildcards; see how they are used in practice in our OSPF guide.
Route summarization is subnetting in reverse: find the shortest prefix that covers several contiguous networks. The four networks 192.168.0.0/24, 192.168.1.0/24, 192.168.2.0/24 and 192.168.3.0/24 summarize to 192.168.0.0/22, because the third octet values 0 to 3 differ only in the last two bits. The set must start on a multiple of the summary block size (4 here) to be summarizable as one route.
Which IPv4 ranges are private or special?
| Range | Purpose | Exam note |
|---|---|---|
| 10.0.0.0/8 | Private (RFC 1918) | About 16.7 million addresses |
| 172.16.0.0/12 | Private (RFC 1918) | Covers 172.16.0.0 to 172.31.255.255 only; 172.32.x.x is public |
| 192.168.0.0/16 | Private (RFC 1918) | Most common home and small-office range |
| 169.254.0.0/16 | Link-local (APIPA) | A host showing this address failed to reach DHCP |
| 127.0.0.0/8 | Loopback | 127.0.0.1 tests the local TCP/IP stack |
| 100.64.0.0/10 | Carrier-grade NAT shared space | Not RFC 1918, but not routable on the public internet |
Every private block above is explained in more detail, with the reasons each one exists, in private IP address ranges.
How is subnetting different in AWS and Google Cloud?
Cloud networks reuse the same math but add provider rules. In an AWS VPC, each subnet reserves 5 addresses (network, VPC router, DNS, reserved for future use, and broadcast), and IPv4 subnet sizes range from /28 to /16. Google Cloud reserves 4 addresses in each primary IPv4 subnet range (network, default gateway, second-to-last, and broadcast). So a /28 gives 11 usable addresses on AWS and 12 on Google Cloud. If you are studying for the Google ACE exam, VPC subnet design is covered in our GCP networking fundamentals guide.
Subnetting practice questions with answers
Try each one on paper before opening the answer. Aim for under 45 seconds each, then confirm your work with the free subnet calculator.
1. How many usable hosts does a /27 provide?
30. Host bits = 5, 25 = 32, minus 2 = 30.
2. What are the network and broadcast addresses of 192.168.14.157/28?
Block size 16. The largest multiple of 16 that is at most 157 is 144. Network 192.168.14.144, broadcast 192.168.14.159, usable 145 to 158.
3. Which prefix supports 500 hosts?
/23. You need 9 host bits (29 = 512, 510 usable); 32 − 9 = 23.
4. Can 10.1.1.127/25 be assigned to a host?
No. A /25 has a block size of 128, so 10.1.1.0/25 spans .0 to .127 and .127 is the broadcast address.
5. How many /20 subnets fit inside 172.16.0.0/16, and how many hosts does each have?
Borrowed bits = 20 − 16 = 4, so 24 = 16 subnets. Each has 12 host bits, so 4,094 usable hosts.
6. What is the dotted-decimal mask for /21?
255.255.248.0. The third octet has 5 bits set: 128+64+32+16+8 = 248.
7. Are 192.168.5.130/26 and 192.168.5.190/26 on the same subnet?
Yes. Block size 64, so both fall inside 192.168.5.128/26 (.128 to .191).
8. A technician assigns 10.20.30.40/30 to a server. What happens?
It fails: 40 is a multiple of the block size 4, so 10.20.30.40 is the network address. The usable hosts are .41 and .42, and the broadcast is .43.
For many more timed questions with explanations, see the Network+ practice exam or the CCNA practice exam, and the full question bank if you want unlimited attempts.
Where does subnetting fit in your CCNA study plan?
On CCNA, subnetting is both a standalone skill and a prerequisite for IP connectivity and routing questions, so it belongs in the first two weeks of any plan. Our CCNA study plan schedules it before routing, and the CCNA exam guide shows how IP addressing fits in the blueprint.
What are the most common subnetting mistakes?
| Mistake | Why it happens | Fix |
|---|---|---|
| Forgetting to subtract 2 | Rushing; the question asks for hosts, not addresses | Write "minus 2" on your scratch paper before you start |
| Working in the wrong octet | A mask like /20 puts the boundary in the third octet | Find the octet where the mask is not 255 or 0 first |
| Off-by-one broadcast | Using the network address plus block size | Broadcast = next network minus 1 |
| Treating .0 or .255 as always invalid | Learned only on /24 examples | Only the all-zero and all-one host patterns are reserved |
| Confusing mask and wildcard | Both look like dotted decimals | Wildcard = 255.255.255.255 minus mask |
| Sizing without the gateway | Counting only end devices | Add the router interface to the host count |
Memory aids: the bit values double right to left (1, 2, 4, 8, 16, 32, 64, 128); the mask octets build left to right (128, 192, 224, 240, 248, 252, 254, 255); and "block size = 256 minus mask" is the one equation to write at the top of your exam scratch sheet.
Frequently asked questions
What is subnetting in one sentence?
Subnetting is dividing one large IP network into smaller, logically separate segments by borrowing bits from the host portion of an address to extend the network portion — trading total address space for more, smaller networks.
What is the fastest way to calculate usable hosts from a CIDR prefix?
Subtract the prefix from 32 to get host bits, raise 2 to that power for total addresses, then subtract 2 for the network and broadcast addresses. A /27 has 5 host bits (32−27), 2^5 = 32 total addresses, 30 usable. The two exceptions are /31 (both addresses usable, no network/broadcast reserved) and /32 (a single host route).
What is VLSM and why does it matter?
Variable Length Subnet Masking (VLSM) means using different prefix lengths for different subnets carved from the same address block, sized to each subnet’s actual host requirement instead of one fixed size for everything. It is the standard real-world approach because a flat subnet size wastes address space on small subnets and under-serves large ones.
Does IPv6 use subnetting the same way as IPv4?
The concept is the same — borrowing bits to create smaller networks — but the math differs significantly. IPv6 has no broadcast address (multicast replaces it), address space is vastly larger, and the common real-world practice is allocating /64 subnets uniformly rather than VLSM-style variable sizing, since address exhaustion is not the same constraint it is in IPv4.
Which certifications test subnetting?
It appears on nearly every networking and many security certifications: CompTIA Network+, Security+, and the CCST tier are heavily subnetting-dependent; Cisco CCNA tests it at similar depth plus VLSM design scenarios; even cloud certifications (AWS, Google Cloud, Azure) test a lighter version of it for VPC/subnet sizing.
How do I find the network address of an IP address?
Find the interesting octet (where the mask is not 255 or 0), calculate block size as 256 minus the mask value, and round the address octet down to the nearest multiple of the block size; octets to the right become 0. For 192.168.14.157/28 the block size is 16, so the network address is 192.168.14.144.
What is the difference between a subnet mask and a wildcard mask?
A subnet mask marks network bits with 1s and host bits with 0s. A wildcard mask is the exact inverse, used by access lists and OSPF network statements: 0 means the bit must match and 1 means ignore it. A /24 mask of 255.255.255.0 has the wildcard 0.0.0.255.
Sources and further reading
- RFC 4632: Classless Inter-domain Routing (CIDR)
- RFC 3021: Using 31-Bit Prefixes on IPv4 Point-to-Point Links
- RFC 1918: Address Allocation for Private Internets
- AWS VPC documentation: subnet CIDR blocks and sizing
- Google Cloud documentation: VPC subnets and reserved addresses
Test yourself on subnetting
30 free Network+ questions cover subnetting scenarios directly — no signup, no credit card. Full 500-question bank is $11.99 lifetime, or $9.99/month Pro unlocks every CertSharp certification.