What Is Subnetting?
Subnetting divides a single IP network into smaller, logical subnetworks (subnets). It reduces broadcast domains, improves security, and makes more efficient use of scarce IPv4 address space. Each subnet functions as its own routed segment.
Instead of a flat 192.168.1.0/24 for 254 hosts, you might split it into four /26 subnets — each supporting 62 hosts — isolating departments or environments behind a router.
CIDR Notation
Classless Inter-Domain Routing (CIDR) specifies an IP address and its prefix length: the number of leading 1 bits in the subnet mask.
192.168.1.0/24 → mask 255.255.255.0 → 24 network bits 10.0.0.0/8 → mask 255.0.0.0 → 8 network bits 172.16.0.0/12 → mask 255.240.0.0 → 12 network bits
The prefix length directly tells you how many addresses belong to the network: 2(32 − prefix) total addresses per subnet.
Subnet Mask Reference
Every CIDR prefix maps to a dotted-decimal subnet mask. This table covers the most common values:
| CIDR | Mask | Hosts | Usable |
|---|---|---|---|
/8 | 255.0.0.0 | 16,777,216 | 16,777,214 |
/12 | 255.240.0.0 | 1,048,576 | 1,048,574 |
/16 | 255.255.0.0 | 65,536 | 65,534 |
/20 | 255.255.240.0 | 4,096 | 4,094 |
/24 | 255.255.255.0 | 256 | 254 |
/25 | 255.255.255.128 | 128 | 126 |
/26 | 255.255.255.192 | 64 | 62 |
/27 | 255.255.255.224 | 32 | 30 |
/28 | 255.255.255.240 | 16 | 14 |
/29 | 255.255.255.248 | 8 | 6 |
/30 | 255.255.255.252 | 4 | 2 |
/32 | 255.255.255.255 | 1 | 1 |
Dividing a Network: Step by Step
1. Determine requirements
How many subnets are needed? What is the largest subnet's host count? Always round up to the next power of 2.
2. Calculate borrow bits
If you need N subnets, borrow ⌈log₂(N)⌉ bits from the host portion. The new prefix is original + borrow.
Example: 192.168.1.0/24 needs 4 subnets borrow = log₂(4) = 2 bits new prefix = 24 + 2 = /26 Each /26 has 64 addresses, 62 usable.
3. List the subnet ranges
Increment the network address by the block size (2(32 − new_prefix)).
Subnet 0: 192.168.1.0/26 (1.1–1.63) Subnet 1: 192.168.1.64/26 (1.65–1.127) Subnet 2: 192.168.1.128/26 (1.129–1.191) Subnet 3: 192.168.1.192/26 (1.193–1.255)
4. Assign and document
Allocate subnets to VLANs, locations, or functions. Record the subnet, mask, gateway, and DHCP scope in your IPAM.
VLSM — Variable-Length Subnet Masks
Classful subnetting forces every subnet to use the same mask, wasting addresses. VLSM lets you apply different prefix lengths to different subnets, matching host count exactly.
Network: 10.0.0.0/16 Site A — 500 hosts → /23 (512 addr) Site B — 250 hosts → /24 (256 addr) Site C — 60 hosts → /26 ( 64 addr) Site D — 2 hosts → /30 ( 4 addr — point-to-point)
Arrange subnets from largest to smallest to avoid overlap. VLSM is fundamental to modern OSPF, EIGRP, and BGP designs.
Supernetting (Route Summarization)
The inverse of subnetting: combine contiguous subnets into a larger block to reduce routing table entries. Also called route aggregation or prefix summarization.
192.168.0.0/24 192.168.1.0/24 192.168.2.0/24 192.168.3.0/24 → 192.168.0.0/22 (covers all four)
For summarization, find the common prefix where all networks share identical bits; that becomes the summary route. The remaining bits cover the variation.
Common Pitfalls
- Forgetting the network and broadcast addresses — never assign them to a host.
- Overlapping subnets — a classic routing black hole. Double-check your ranges.
- Too-large subnets — a /24 for a point-to-point link wastes 252 addresses.
- Not planning for growth — leave headroom; renumbering is painful.
- Misconfiguring the subnet mask — a single wrong bit can isolate hosts.
Quick Reference — Powers of Two
| Bits | Value | Bits | Value |
|---|---|---|---|
| 20 | 1 | 28 | 256 |
| 21 | 2 | 29 | 512 |
| 22 | 4 | 210 | 1,024 |
| 23 | 8 | 211 | 2,048 |
| 24 | 16 | 212 | 4,096 |
| 25 | 32 | 213 | 8,192 |
| 26 | 64 | 214 | 16,384 |
| 27 | 128 | 215 | 32,768 |
Memorise the /24 through /30 range — it covers 99% of real-world subnetting scenarios.