There are two common ways to express a subnetting requirement: "I need subnets each with at least N hosts" or "I need at least M subnets from my parent network." Both produce a prefix length, but the math is different. Knowing both methods makes you faster at the right one for any given question.
This article works through both approaches with examples, and shows how they connect to each other.
Method 1: subnetting by host count
You know how many hosts each subnet must hold. Find the smallest prefix that accommodates that count.
Formula
- You need N hosts.
- You need at least N + 2 total addresses (network + broadcast not usable).
- Round up to the next power of 2.
- Prefix = 32 − log₂(that power).
Quick reference
| Hosts needed | Min total addresses | Next power of 2 | Prefix | Usable |
|---|---|---|---|---|
| 2 | 4 | 4 | /30 | 2 |
| 6 | 8 | 8 | /29 | 6 |
| 10 | 12 | 16 | /28 | 14 |
| 25 | 27 | 32 | /27 | 30 |
| 50 | 52 | 64 | /26 | 62 |
| 100 | 102 | 128 | /25 | 126 |
| 250 | 252 | 256 | /24 | 254 |
| 500 | 502 | 512 | /23 | 510 |
| 1,000 | 1,002 | 1,024 | /22 | 1,022 |
Example
You need 60 hosts per subnet. Round 62 up to 64. Prefix = 32 − 6 = /26 (62 usable).
Method 2: subnetting by subnet count
You know how many subnets you need to carve from a parent network. Find the smallest number of bits to borrow.
Formula
- You need M subnets.
- Borrow B bits where 2^B ≥ M.
- New prefix = parent_prefix + B.
Quick reference
| Subnets needed | Bits to borrow | Total subnets created |
|---|---|---|
| 1 | 0 | 1 |
| 2 | 1 | 2 |
| 3-4 | 2 | 4 |
| 5-8 | 3 | 8 |
| 9-16 | 4 | 16 |
| 17-32 | 5 | 32 |
| 33-64 | 6 | 64 |
| 65-128 | 7 | 128 |
| 129-256 | 8 | 256 |
Example
You have 10.0.0.0/16 and need 10 subnets. Borrow 4 bits (2^4 = 16 ≥ 10). New prefix = 16 + 4 = /20. You get 16 subnets, each with 4,094 usable hosts.
The two methods connected
If you take a parent /16 and need 10 subnets each with 200 hosts, both methods agree:
- By host count: 200 hosts → /24 → fits in a /16 easily.
- By subnet count: 10 subnets from a /16 → /20. But each /20 has 4,094 hosts, much more than 200 needed.
This is the conflict. Using only the subnet-count method, you would carve into /20s, but each /20 is wildly over-sized for 200 hosts each. Using only the host-count method, you'd carve /24s, but you could carve 256 of them — way more than 10 needed, and you "lose" the smaller subnets from being directly usable.
The host-count method is almost always what you actually want. The subnet-count method is mostly an artifact of legacy classful subnetting where each subnet was constrained to a fixed prefix length. With VLSM (which is now universal), you can have different-sized subnets, so size each to its actual hosts.
Method 3 (bonus): the combined VLSM approach
For real-world subnetting, you usually have a mix of requirements — some subnets need 250 hosts, others need 14, others need 2. The combined approach is VLSM:
- Use the host-count method for each subnet independently.
- Allocate from a parent network largest-first.
- Each subnet is exactly the size it needs to be.
See our VLSM article for the full worked example.
Where the subnet-count method still matters
Despite VLSM being the modern default, the subnet-count method comes up in a few practical contexts:
- Cloud subnet provisioning: "I have a /16 VPC and want 12 equal-sized subnets." Borrow 4 bits → /20s. All equal. Suitable when subnets serve identical functions (e.g., one per AZ for a uniform tier).
- OSPF / EIGRP area design: Each area gets a /N subnet. Subnet count determines how many areas you can carve.
- CCNA exam questions: Some questions are phrased as "how many subnets if you use prefix /X" — explicit subnet-count framing.
The "minimum hosts per subnet" trap
If a question says "minimum 50 hosts per subnet," people often forget the +2 for network and broadcast. 50 hosts → /26 (62 usable), not /27 (30 usable, which fails the requirement).
Triple-check: usable count = 2^(32-prefix) − 2. The −2 is critical.
Common questions
"How many /24s in a /16?"
2^(24-16) = 2^8 = 256.
"How many /28s in a /24?"
2^(28-24) = 2^4 = 16.
"How many subnets of any size in a /16, given some are /20 and some are /24?"
Now VLSM. Each /20 consumes 1/16 of the parent, each /24 consumes 1/256. Use a tool like our VLSM Designer to plan it.
Cloud-specific reservations
For AWS, Azure, and GCP, subtract 3-5 from the usable count to account for cloud-reserved IPs. See our AWS reserved IPs article for details.
Key takeaways
- Host-count method: round (hosts + 2) up to next power of 2, compute prefix from there. Use this 95% of the time.
- Subnet-count method: borrow B bits where 2^B ≥ M subnets needed. Useful when all subnets are equal-sized.
- Modern subnetting uses VLSM: combine host-count sizing with largest-first allocation from a parent network.
- Always remember −2 for network and broadcast (except /31, which has 2 usable per RFC 3021).