How to calculate an IPv4 subnet, with a worked example
Every IPv4 subnet question comes down to one operation: a bitwise AND between the address and the subnet mask. Once that clicks, the network address, broadcast address and host range follow directly. Here it is worked through for 192.168.10.77/26.
1. Turn the prefix into a mask
/26 means the first 26 of the 32 bits are network bits:
11111111.11111111.11111111.11000000 = 255.255.255.192
Only the last octet is interesting here. The 6 host bits give a block size of 26 = 64 addresses.
2. AND the address with the mask
77 = 01001101
192 = 11000000
AND = 01000000 = 64
So the network address is 192.168.10.64. A shortcut that gives the same
answer: blocks of 64 start at 0, 64, 128 and 192, and 77 falls in the block that starts at 64.
3. Read off the rest
- Broadcast address: last address of the block, 64 + 64 − 1 =
192.168.10.127 - Usable hosts:
192.168.10.65to192.168.10.126— 64 − 2 = 62 hosts - Wildcard mask (used in ACLs): 255.255.255.255 − 255.255.255.192 =
0.0.0.63
The general formula for usable hosts is 2(32 − prefix) − 2, because the first address
identifies the network and the last is the broadcast. Two exceptions: a /31 has two usable
addresses for point-to-point links (RFC 3021), and a /32 is a single host.
Check your answer
Enter 192.168.10.77 and prefix 26 in the
IP Subnet Calculator. It shows the same network
(192.168.10.64), broadcast (192.168.10.127), host range, 62 usable hosts, and the mask in binary
(11111111 11111111 11111111 11000000) so you can compare it with your working.
Splitting a /24 into smaller subnets
Borrowing 2 bits from the host part of 192.168.10.0/24 gives 22 = 4 subnets
of /26, each with 62 usable hosts:
192.168.10.0/26 hosts .1 – .62 broadcast .63
192.168.10.64/26 hosts .65 – .126 broadcast .127
192.168.10.128/26 hosts .129 – .190 broadcast .191
192.168.10.192/26 hosts .193 – .254 broadcast .255
To convert individual octets between binary, decimal and hex while practising, use the number base converter.
Questions
How many hosts are in a /27?
2^(32−27) − 2 = 30 usable hosts, in blocks of 32 addresses.
Is 192.168.10.64 a valid host address in a /26?
No. In 192.168.10.64/26 it is the network address; the first usable host is 192.168.10.65.