How do you divide 192.168.1.0/24 into four equal subnets?
Borrow 2 host bits (2^2 = 4 subnets) to get /26. The subnets are 192.168.1.0/26, .64/26, .128/26 and .192/26, each with 64 addresses and 62 usable hosts.
Explain it simply
A /24 is a floor of 256 rooms. To make four equal wings, you need to name each wing with 2 extra bits, since two bits give four combinations (00, 01, 10, 11). Each wing then has 256 divided by 4 = 64 rooms.
Example
/24 + 2 borrowed bits = /26 mask 255.255.255.192
Subnet 1 192.168.1.0/26 hosts .1 - .62 broadcast .63
Subnet 2 192.168.1.64/26 hosts .65 - .126 broadcast .127
Subnet 3 192.168.1.128/26 hosts .129 - .190 broadcast .191
Subnet 4 192.168.1.192/26 hosts .193 - .254 broadcast .255Check: 4 subnets times 62 usable hosts is 248 usable, whereas the original /24 had 254. The 6 lost addresses are the extra network and broadcast addresses (4 x 2 = 8, minus the 2 that a single /24 would have used).
If the question asked for 5 subnets instead, round up to the next power of two (8), borrow 3 bits, and use /27. Each would hold 30 hosts.
What to say in the interview
"For N subnets I borrow enough bits that 2 to the power of bits is at least N. Four subnets need 2 bits, so /24 becomes /26, with a block size of 64: 0, 64, 128 and 192."
Common mistakes
- Forgetting that more subnets mean fewer hosts per subnet.