Which one of the following CIDR prefixes exactly represents the range of IP addresses 10.12.2.0 to 10.12.3.255?
- (A)
10.12.2.0/23
- (B)
10.12.2.0/24
- (C)
10.12.0.0/22
- (D)
10.12.2.0/22
Which one of the following CIDR prefixes exactly represents the range of IP addresses 10.12.2.0 to 10.12.3.255?
10.12.2.0/23
10.12.2.0/24
10.12.0.0/22
10.12.2.0/22
ANSWER
The prefix that exactly represents the range is 10.12.2.0/23, option (A).
Official answer: ASource: Official answer key, GATE 2024 CS2 (IISc Bengaluru)
Count the addresses in the range 10.12.2.0 to 10.12.3.255. The third octet takes the values 2 and 3, and the fourth octet runs over 0 to 255 for each. That gives addresses.
A CIDR block of addresses has 9 host bits, so its prefix length is . Only option (A) has a /23 prefix.
Check that 10.12.2.0 is a valid /23 network address. In binary the third octet is 00000010. A /23 prefix fixes the first 7 bits of the third octet (0000001), and the last bit is a host bit. That host bit is 0, so all host bits of 10.12.2.0 are zero and it is a valid /23 network address.
The block 10.12.2.0/23 covers third octets 0000001x, that is 2 and 3, with any fourth octet. It therefore spans 10.12.2.0 to 10.12.3.255, which is exactly the given range.
Check the other options. (B) 10.12.2.0/24 covers only 256 addresses (10.12.2.0 to 10.12.2.255), so it is too small. (C) 10.12.0.0/22 covers 1024 addresses (10.12.0.0 to 10.12.3.255), so it is too large. (D) 10.12.2.0/22 is also a 1024-address block, so it is too large. It is not even a proper network address, because a /22 block must start at a third octet that is a multiple of 4 (here 10.12.0.0). Only (A) matches the range exactly.
KEY IDEA
The block size fixes the prefix length . The start address must also have all its host bits zero, which means it must be aligned to a multiple of the block size.
WATCH OUT FOR
Picking a /22 because the range ends at 10.12.3.255 and "looks like" a /22 boundary. A /22 would have to start at 10.12.0.0 and would include 10.12.0.0 to 10.12.1.255, which are outside the range. Another slip is counting only the third octet's two values and answering /24.
From the GATE 2024 CS2 paper. Every question of this paper · Download the full paper · All 20 IPv4 questions, with notes