The key idea
There is one part of subnetting that seems trivial until you realize it is where many exercises go wrong: how many hosts does a subnet actually need?
If you estimate the host requirement incorrectly, you choose the wrong block size, which means the prefix will be wrong too. And once the prefix is wrong, everything else—increment, ranges, broadcast—falls apart after it.
Hosts vs addresses: they are not the same thing
In typical IPv4 exercises, a subnet contains an address block, and inside that block you have:
- Network: the first address, which identifies the subnet
- Broadcast: the last address, used for broadcast
- Hosts: the usable addresses in between
So when someone says “I need 50 hosts,” what you should actually think is: “I need a block with enough addresses for 50 hosts plus 2 reserved addresses.”
Quick method: hosts + 2 and the smallest power of two
This is the workflow that saves you in an exam and keeps you from guessing:
- Take the host count you need as usable addresses.
- Add 2 for network + broadcast.
- Find the smallest power of two that can cover that number.
- That power of two is your block size, meaning total addresses.
- Use the block size to determine the prefix.
Quick example: 50 hosts
- 50 + 2 = 52 required addresses
- Smallest power ≥ 52 → 64
- Block size 64 → usable hosts 64 − 2 = 62
How to turn a block size into a prefix without memorizing
IPv4 has 32 bits. If your block contains 64 addresses:
- 64 = 2⁶ ⇒ you need 6 host bits
- Prefix = 32 − 6 = /26
block = 2^h
host_bits = h
prefix = 32 - h
A useful mental table
You do not need to memorize everything, but these ranges cover most common exercises:
| Hosts needed (approx.) | Block (addresses) | Usable hosts | Prefix |
|---|---|---|---|
| up to 2 | 4 | 2 | /30 |
| up to 6 | 8 | 6 | /29 |
| up to 14 | 16 | 14 | /28 |
| up to 30 | 32 | 30 | /27 |
| up to 62 | 64 | 62 | /26 |
| up to 126 | 128 | 126 | /25 |
| up to 254 | 256 | 254 | /24 |
Common examples to master the pattern
Example A: I need 12 hosts
- 12 + 2 = 14
- Smallest power ≥ 14 → 16
- 16 = 2⁴ ⇒ prefix = 32 − 4 = /28
- Usable hosts = 16 − 2 = 14
Example B: I need 100 hosts
- 100 + 2 = 102
- Smallest power ≥ 102 → 128
- 128 = 2⁷ ⇒ prefix = 32 − 7 = /25
- Usable hosts = 128 − 2 = 126
Example C: I need 2 hosts for a typical point-to-point link
- 2 + 2 = 4
- Smallest block = 4
- 4 = 2² ⇒ prefix = 32 − 2 = /30
- Usable hosts = 2
Common mistakes when estimating hosts
Forgetting network and broadcast
If you need 30 hosts and choose a block of 30 “because it fits,” you are already off track: block sizes follow powers of two, and two addresses are reserved as well.
Choosing a prefix out of habit
Many people pick /24, /26, or /27 because it “looks right” without doing the calculation. In an exam, you are usually expected to choose the smallest prefix that satisfies the requirement.
Confusing hosts with subnets
“I need 8 subnets” is not solved the same way as “I need 8 hosts.” They are two different calculations: borrowed bits versus host bits.
Final checklist
- Are the requested hosts usable hosts?
- Did I calculate hosts + 2 for network + broadcast?
- Did I choose the smallest power of two that covers the requirement?
- Do I know how many host bits that block needs?
- Is prefix = 32 − host_bits?
- Did I quickly verify it with CIDR → Hosts?
