Hosts in a /26 — OS, DBMS & Networks Aptitude Question
Hosts in a /26: How many usable host addresses does an IPv4 subnet with a /26 prefix provide? Answer and worked solution on CodeKairo.
- Topic: OS, DBMS & Networks
- Section: Programming MCQs
- Difficulty: Medium
- Time target: 75 seconds
Question
How many usable host addresses does an IPv4 subnet with a /26 prefix provide?
Options
- 30
- 62
- 64
- 126
Show the answer and the worked solution
Correct answer: B. 62
Worked solution
- A /26 prefix leaves 32 − 26 = 6 bits for the host part.
- Six bits address 2^6 = 64 distinct values within the subnet.
- The all-zeros value names the network and the all-ones value is the broadcast address, so 64 − 2 = 62 addresses remain usable by hosts.
Answer: 62.
The idea
The formula is 2^(32 − prefix) − 2. Forgetting to subtract the network and broadcast addresses is what the neighbouring distractor is there to catch.
Shortcut. A /26 is a quarter of a /24's 256 addresses, 64, and removing the network and broadcast addresses leaves 62.
Common trap. 64 counts all 2⁶ addresses and forgets that the all-zeros and all-ones host values are reserved.