Last reviewed: May 2026
Subnetting is the skill of dividing a large IP address block into smaller networks. It's tested on every networking certification (CCNA, JNCIA, CompTIA Network+) and used daily by network engineers and cloud architects. This guide teaches you two methods: binary subnetting (exact, great for understanding) and the magic number method (fast, great for exams and real work).
Verify your subnets instantly →An IPv4 address is 32 bits written as four decimal octets, e.g. 192.168.10.5. Every address has two parts:
The subnet mask (or CIDR prefix) divides the address into these two parts. All addresses with the same network portion are in the same subnet.
The magic number method lets you find subnet ranges without binary math. It works in the "interesting octet" — the octet where the network-to-host boundary falls.
255.255.255.192 — the fourth octet (192) is interesting.
Mask: 255.255.255.192. Interesting octet: 4th. Magic number: 256 − 192 = 64.
| Subnet | Network | First Host | Last Host | Broadcast | Usable |
|---|---|---|---|---|---|
| #1 | 192.168.1.0 | 192.168.1.1 | 192.168.1.62 | 192.168.1.63 | 62 |
| #2 | 192.168.1.64 | 192.168.1.65 | 192.168.1.126 | 192.168.1.127 | 62 |
| #3 | 192.168.1.128 | 192.168.1.129 | 192.168.1.190 | 192.168.1.191 | 62 |
| #4 | 192.168.1.192 | 192.168.1.193 | 192.168.1.254 | 192.168.1.255 | 62 |
Binary subnetting converts everything to bits. It's slower but builds deep understanding of how subnetting actually works.
These three formulas cover every subnetting question:
| What to find | Formula | Example (/26) |
|---|---|---|
| Number of subnets from a /N split into /M | 2(M−N) | /24 → /26: 22 = 4 subnets |
| Total host addresses per subnet | 2(32−M) | /26: 26 = 64 addresses |
| Usable host addresses per subnet | 2(32−M) − 2 | /26: 64 − 2 = 62 hosts |
VLSM lets you assign different-sized subnets to different segments, matching subnet size to actual need. This is how real networks are designed.
Allocate the biggest subnet first. Starting with the largest block prevents fragmentation and ensures each subnet stays within the parent block.
Step 1 — Find minimum subnet sizes (need 2n − 2 ≥ required hosts):
| Segment | Hosts Needed | Subnet Size | Usable Hosts |
|---|---|---|---|
| Floor 1 LAN | 100 | /25 | 126 |
| Floor 2 LAN | 50 | /26 | 62 |
| Server VLAN | 20 | /27 | 30 |
| Management | 6 | /29 | 6 |
| WAN link | 2 | /30 | 2 |
Step 2 — Assign largest-first from 10.1.0.0/24:
| Segment | Assigned CIDR | Range | Used / Avail |
|---|---|---|---|
| Floor 1 LAN | 10.1.0.0/25 | 10.1.0.1 – 10.1.0.126 | 100 / 126 |
| Floor 2 LAN | 10.1.0.128/26 | 10.1.0.129 – 10.1.0.190 | 50 / 62 |
| Server VLAN | 10.1.0.192/27 | 10.1.0.193 – 10.1.0.222 | 20 / 30 |
| Management | 10.1.0.224/29 | 10.1.0.225 – 10.1.0.230 | 6 / 6 |
| WAN link | 10.1.0.232/30 | 10.1.0.233 – 10.1.0.234 | 2 / 2 |
Total used: 10.1.0.0–10.1.0.235. Remaining: 10.1.0.236–10.1.0.255 (20 addresses for future growth).
| CIDR | Mask (last 2 octets) | Magic Number (4th octet) | Block Size | Usable Hosts |
|---|---|---|---|---|
| /24 | .255.0 | 256 | 256 | 254 |
| /25 | .255.128 | 128 | 128 | 126 |
| /26 | .255.192 | 64 | 64 | 62 |
| /27 | .255.224 | 32 | 32 | 30 |
| /28 | .255.240 | 16 | 16 | 14 |
| /29 | .255.248 | 8 | 8 | 6 |
| /30 | .255.252 | 4 | 4 | 2 |