IPv4 addresses and subnet sizes: Class 12 practice
An IPv4 address has 32 bits. Read the method, follow the three worked examples, then try the six questions.
What you should know first
- Powers of 2
The idea behind ipv4 addresses and subnet sizes
An IPv4 address has 32 bits. With a /n prefix, 32 − n bits identify hosts, giving 2^(32−n) addresses of which 2^(32−n) − 2 are usable hosts (network and broadcast are reserved).
Step-by-step method
- Host bits = 32 − prefix.
- Addresses = 2^(host bits).
- Usable = addresses − 2.
Worked example 1 (Basic)
How many usable host addresses does a /26 network have?
- Host bits = 6
- 2^6 − 2 = 62
- Answer: 62
Worked example 2 (Standard)
How many usable host addresses does a /20 network have?
- Host bits = 12
- 2^12 − 2 = 4094
- Answer: 4094
Worked example 3 (Challenge)
What is the longest prefix that still gives at least 67 usable hosts?
- Need 2^h − 2 ≥ 67 → h = 7
- Prefix = 32 − 7 = /25
- Answer: /25
Common mistakes and misconceptions
- Forgetting to subtract 2
- Using the prefix as host bits
Practice questions
- (Basic) How many usable host addresses does a /27 network have?
- (Basic) How many usable host addresses does a /30 network have?
- (Standard) How many usable host addresses does a /24 network have?
- (Standard) How many usable host addresses does a /21 network have?
- (Challenge) What is the longest prefix that still gives at least 572 usable hosts?
- (Challenge) What is the longest prefix that still gives at least 840 usable hosts?
Answer key with full working
- Q1: Host bits = 5 → 2^5 − 2 = 30 → Answer: 30
- Q2: Host bits = 2 → 2^2 − 2 = 2 → Answer: 2
- Q3: Host bits = 8 → 2^8 − 2 = 254 → Answer: 254
- Q4: Host bits = 11 → 2^11 − 2 = 2046 → Answer: 2046
- Q5: Need 2^h − 2 ≥ 572 → h = 10 → Prefix = 32 − 10 = /22 → Answer: /22
- Q6: Need 2^h − 2 ≥ 840 → h = 10 → Prefix = 32 − 10 = /22 → Answer: /22
Syllabus note
This skill is listed under "Computer Networks" for Class 12 in the NCERT/CBSE books. ICSE, IGCSE, IB and state boards may teach it in a different chapter or year.
Answers on this page are generated and automatically re-checked by a second, independent calculation. They have not been reviewed by a teacher — if you spot a problem, tell us on WhatsApp.
Related practice and notes
Frequently asked questions
Which chapter is ipv4 addresses and subnet sizes in?
"Computer Networks", Class 12 Computer Science (NCERT/CBSE). Other boards may place it differently.
How were the answers checked?
Answers on this page are generated and automatically re-checked by a second, independent calculation. They have not been reviewed by a teacher — if you spot a problem, tell us on WhatsApp.