IPv4 Subnet Calculation: Mask, Range and Hosts
Find the block containing an address
Subnetting divides an address block into smaller aligned blocks. For 192.0.2.70/26, six bits can vary, so the block holds 64 addresses. The block starts at 192.0.2.64 and ends at 192.0.2.127. In a conventional broadcast LAN, the first and last addresses are reserved for the network identifier and directed broadcast; 62 remain for interfaces, including any gateway. The examples use documentation addresses and are calculations only.
Address: 192.0.2.70/26Mask: 255.255.255.192Network: 192.0.2.64Last: 192.0.2.127Usable: 192.0.2.65–192.0.2.126Calculate with binary AND
For prefix length p, write p leading ones followed by 32 − p zeroes. AND the mask with the address to obtain the first address. Set all variable bits to one for the last address. For /26 the last mask octet is 192. In the example the final octet 70 AND 192 equals 64; adding 63 gives 127.
70 = 01000110192 = 11000000AND = 01000000 = 64Last= 01111111 = 127Use a block-size shortcut
Within a /24, /26 block starts are 0, 64, 128 and 192. Divide the final octet by 64, round down and multiply by 64. For 70 this gives 64. A /27 has 32 addresses: 198.51.100.99/27 starts at .96, ends at .127 and has usable .97–.126. For prefixes crossing octet boundaries, use full 32-bit arithmetic rather than this last-octet shortcut.
Count addresses and avoid off-by-one errors
Total addresses = 2^(32 − p). In the conventional LAN case with p ≤ 30, capacity is total minus two; special-purpose address restrictions and platform reservations can further limit assignment. Do not subtract the gateway twice: it consumes one of the usable addresses only if required. The next lesson handles /31 and /32.
Practice
For 203.0.113.145/27, derive mask, network, last address and usable interval. Verify using both AND and the 32-address block shortcut. Explain why 145 is not the start.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
IPv4 subnet calculation — knowledge check
Apply subnetting concepts to fictional offline scenarios.
What network contains 192.0.2.145/27?
What is the mask for /26?
How many conventional usable addresses does a /27 provide?
What is the directed broadcast for 198.51.100.96/27 on a conventional LAN?
A /26 LAN needs one gateway. How many other interfaces can it address before additional reservations?