How to Subnet IPv4 Networks
Subnetting is the process of dividing a large IP network into smaller segments. Every router, every network design, and every CompTIA Network+ exam question about subnetting follows the same rules — once you understand them, the maths becomes quick and predictable.
Why subnetting exists
Without subnetting, every device on a network would be in the same broadcast domain. A broadcast sent by one device reaches every other device — fine for 20 hosts, catastrophic for 2,000. Subnetting creates smaller broadcast domains, improves security (devices in different subnets need a router to communicate), and makes IP address allocation efficient.
IPv4 address structure
Every IPv4 address is 32 bits, written as four octets (e.g. 192.168.1.100). The address has two parts:
- Network portion — identifies which network the address belongs to
- Host portion — identifies the specific device within that network
The subnet mask (or CIDR prefix) defines where the split is. A /24 means the first 24 bits are network, the last 8 are host.
CIDR notation
CIDR (Classless Inter-Domain Routing) notation writes the prefix length after a slash: 192.168.1.0/24. This replaces the old class-based system and the verbose dotted-decimal mask (255.255.255.0). Both mean the same thing — you'll need to recognise both on exams.
The fast subnetting method
On timed exams you need a method that works in under 30 seconds. Here it is:
Step 1 — Find the block size
Block size = 256 − interesting octet of the subnet mask. For a /26 the mask is 255.255.255.192, so block size = 256 − 192 = 64.
Step 2 — List the network addresses
Starting from 0, add the block size each time: 0, 64, 128, 192. These are your four /26 networks within a /24.
Step 3 — Find the ranges
Given 192.168.1.100/26: the host (100) falls in the 64–127 range. So:
Network address: 192.168.1.64 First usable host: 192.168.1.65 Last usable host: 192.168.1.126 Broadcast: 192.168.1.127
Common prefix reference
| Prefix | Mask | Hosts | Block size |
|---|---|---|---|
| /24 | 255.255.255.0 | 254 | 256 |
| /25 | 255.255.255.128 | 126 | 128 |
| /26 | 255.255.255.192 | 62 | 64 |
| /27 | 255.255.255.224 | 30 | 32 |
| /28 | 255.255.255.240 | 14 | 16 |
| /29 | 255.255.255.248 | 6 | 8 |
| /30 | 255.255.255.252 | 2 | 4 |
VLSM — Variable Length Subnet Masking
VLSM lets you assign different-sized subnets to different segments, wasting as few addresses as possible. The approach: sort your requirements largest to smallest, assign the smallest subnet that fits each one.
Example: you need subnets for 50 hosts, 20 hosts, and a point-to-point WAN link. Assign /26 (62 hosts), /27 (30 hosts), and /30 (2 hosts) respectively.