IPv4 subnetting tutorial
Subnetting divides a large IPv4 address block into smaller, manageable networks. Understanding how to read a CIDR prefix lets you calculate a subnet's network address, broadcast address, usable host range, and host count — the four values that appear in nearly every subnetting question and in real router configuration work.
IPv4 address anatomy
An IPv4 address is 32 bits long, written as four groups of 8 bits each in dotted-decimal notation. For example, 192.168.44.77 has four octets: 192, 168, 44, and 77.
CIDR notation appends a slash and a number to the address, like 192.168.44.77/27. That number is the prefix length. It tells you how many of the 32 bits are fixed as the network portion. The remaining bits identify individual hosts within that network.
/27 bit layout
← 27 network bits ─── 5 host bits →
11111111.11111111.11111111.11100000
subnet mask: 255.255.255.224
Block size and boundaries
The block size is the total number of addresses in one subnet. Calculate it as $2^{(32 - \text{prefix})}$. For /27 that is $2^5 = 32$.
Subnet boundaries in the last octet are always multiples of the block size. Because /27 has a block size of 32, the valid network starting points in the last octet are 0, 32, 64, 96, 128, 160, 192, and 224.
To find which subnet a given host belongs to: divide the host's last-octet value by the block size, drop the remainder, then multiply back. The result is the network address's last octet.
Subnet reference table
This table covers the prefixes used most often in practice problems. Memorising the block size and usable-host count for each prefix lets you skip arithmetic on timed exercises.
| Prefix | Subnet mask | Block size | Total addr. | Usable hosts | Last-octet boundaries |
|---|---|---|---|---|---|
| /24 | 255.255.255.0 | 256 | 256 | 254 | 0 only |
| /25 | 255.255.255.128 | 128 | 128 | 126 | 0, 128 |
| /26 | 255.255.255.192 | 64 | 64 | 62 | 0, 64, 128, 192 |
| /27 | 255.255.255.224 | 32 | 32 | 30 | 0, 32, 64, 96, 128, 160, 192, 224 |
| /28 | 255.255.255.240 | 16 | 16 | 14 | 0, 16, 32, 48, …, 224, 240 |
| /29 | 255.255.255.248 | 8 | 8 | 6 | 0, 8, 16, 24, …, 248 |
| /30 | 255.255.255.252 | 4 | 4 | 2 | 0, 4, 8, 12, …, 252 |
/30 subnets are commonly used for point-to-point router links because they provide exactly two usable addresses.
The five-step calculation method
Every subnetting question asks for the same four values. This method reaches all of them in order.
- Calculate the block size. Host bits = $32 - \text{prefix}$. Block size = $2^{\text{host bits}}$. A /27 gives $2^5 = 32$.
- Find the network address. In the interesting octet, floor-divide the host value by the block size, then multiply back: $\lfloor \text{host} \div \text{block} \rfloor \times \text{block}$. All octets to the left stay the same; all host bits to the right become 0.
- Find the broadcast address. Add block size minus 1 to the network address in the interesting octet: $\text{network} + \text{block} - 1$. All host bits become 1.
- Derive the usable host range. First usable = network address + 1. Last usable = broadcast address − 1.
- Count usable hosts. Block size − 2 (subtract the network and broadcast addresses).
Detailed worked example — /27
Given host address 192.168.44.77/27, find all four subnet values.
| Prefix | /27 → 5 host bits |
| Block size | $2^5 = 32$ |
| Host last octet | 77 |
| Network address | $\lfloor 77 \div 32 \rfloor \times 32 = 2 \times 32 = 64$ → 192.168.44.64 |
| Broadcast address | $64 + 32 - 1 = 95$ → 192.168.44.95 |
| First usable host | 192.168.44.65 |
| Last usable host | 192.168.44.94 |
| Usable host count | $32 - 2 = \mathbf{30}$ |
Quick sanity check: host 77 falls between network 64 and broadcast 95, so the answer is consistent.
Second example — /26
Given host address 10.0.0.200/26.
| Block size | $2^{32-26} = 2^6 = 64$ |
| Network address | $\lfloor 200 \div 64 \rfloor \times 64 = 3 \times 64 = 192$ → 10.0.0.192 |
| Broadcast address | $192 + 64 - 1 = 255$ → 10.0.0.255 |
| Usable host range | 10.0.0.193 – 10.0.0.254 |
| Usable host count | $64 - 2 = \mathbf{62}$ |
Refreshable sample
Try one subnetting question
Use this sample to verify you can find all four key values before working through a full set.
Why subnetting matters in real networks
Subnetting is a core skill for network administrators, help-desk staff, and anyone preparing for certifications like CompTIA Network+ or Cisco CCNA. In production networks it provides:
- Broadcast control. Smaller subnets create smaller broadcast domains, which reduces unnecessary traffic on each segment and improves performance.
- Security segmentation. Placing servers, workstations, and IoT devices in separate subnets makes it straightforward to apply firewall rules between groups.
- Address efficiency. Assigning a right-sized subnet to each department or function avoids wasting large blocks of a limited allocation.
- Route summarisation. Cleanly sized subnets make it easier to write concise routing table entries that cover many hosts in a single line.
Once fixed subnetting is comfortable, the next step is VLSM, which uses different prefix lengths within the same parent block to eliminate wasted space between subnets of different sizes.
Open IPv4 subnetting practice