IP Addressing and Subnetting for Beginners (with Step-by-Step Examples)
Subnetting looks scary because it mixes binary with networking terms, but it is really a short, repeatable method. Once you can do the four steps below, most exam subnetting questions become quick, reliable marks.
1. How an IPv4 address is built
An IPv4 address is 32 bits, written as four octets of 8 bits each, separated by dots, for example 192.168.10.77. Each octet ranges from 0 to 255. Every address has two parts: the network part (which network the device is on) and the host part (which device on that network).
You need the 8-bit place values: 128 64 32 16 8 4 2 1. For example, 77 = 64 + 8 + 4 + 1 = 01001101.
2. Subnet masks and CIDR
The subnet mask says how many bits belong to the network. In binary it is a run of 1s (network bits) followed by 0s (host bits). CIDR notation writes the number of 1s after a slash.
/24=255.255.255.0(24 network bits, 8 host bits)/26=255.255.255.192(26 network bits, 6 host bits)/30=255.255.255.252(30 network bits, 2 host bits)
With h host bits, a subnet has 2h addresses. The first is the network address and the last is the broadcast address, so usable hosts = 2h − 2.
3. The four-step method
- Find the block size in the octet where the mask "breaks": 256 − (mask value in that octet). For /26 the last octet is 192, so the block size is 256 − 192 = 64.
- List the subnets by counting up in block sizes from 0: 0, 64, 128, 192.
- Find the subnet the address falls into: the largest multiple of the block size that is not bigger than the address's octet.
- Work out the range: network address = start of the block, broadcast = next block − 1, usable hosts are everything in between.
4. Example 1: a /26 network
Question: For 192.168.10.0/26, how many subnets of the /24 are there, and what are their ranges?
A /26 borrows 2 bits from the last octet (26 − 24 = 2), giving 22 = 4 subnets. Host bits = 32 − 26 = 6, so each subnet has 26 = 64 addresses and 62 usable hosts. Block size = 64.
| Subnet | Network | Usable hosts | Broadcast |
|---|---|---|---|
| 1 | 192.168.10.0 | .1 – .62 | 192.168.10.63 |
| 2 | 192.168.10.64 | .65 – .126 | 192.168.10.127 |
| 3 | 192.168.10.128 | .129 – .190 | 192.168.10.191 |
| 4 | 192.168.10.192 | .193 – .254 | 192.168.10.255 |
5. Example 2: which subnet is a host in?
Question: A device has the address 192.168.10.77/27. Find the network address, broadcast address and usable range.
- /27 → last octet of the mask is 224 (
11100000). Block size = 256 − 224 = 32. - Subnets: 0, 32, 64, 96, 128 …
- 77 falls between 64 and 96, so it is in the 64 subnet.
- Network = 192.168.10.64, broadcast = 96 − 1 = 192.168.10.95, usable hosts = .65 to .94 (30 hosts).
You can check with binary: ANDing 01001101 (77) with 11100000 (224) gives 01000000 = 64. Same answer.
6. Example 3: designing subnets
Question: You have 10.0.5.0/24 and need subnets with at least 50 hosts each. What prefix should you use?
Find the smallest h where 2h − 2 ≥ 50. 25 − 2 = 30 is too small; 26 − 2 = 62 works, so h = 6. Prefix = 32 − 6 = /26, which gives 4 subnets of 62 usable hosts each.
7. Quick reference table
| CIDR | Mask | Block size | Usable hosts |
|---|---|---|---|
| /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 |
8. Common mistakes
- Forgetting to subtract 2 for the network and broadcast addresses.
- Using the network or broadcast address as a host address.
- Calculating the block size in the wrong octet. Look for the octet where the mask is not 255 or 0.
- Rounding host requirements down: always choose the subnet that fits at least the hosts needed.