# Which addresses belong to which network, given a fixed subnet mask?

The subnet mask for a particular network is 255.255.31.0.
Which of the following IP address belongs to this network?

1. 172.57.88,62 & 172.56.87.233
2. 10.35.28.2 & 10.35.29.4
3. 191.203.31.87 & 191.234.31.88
4. 128.8.129.43 & 128.8.161.55

Little bit confuse about 3rd octet of SM ( i.e .31 ) But got the point that 5 bit was hired from 3rd octet for subnetting.

The principle : convert the dotted-quad IP addresses and mask to 32-bit unsigned integers and AND each address with the mask. If the results are the same, they're in the same subnet.

By using above principle Ans is D.
But Can I do it directly ?
Means

1. By looking at SM it is clear that , it belongs to class B.
2. Option A and C are 2 different networks.( there 2nd octet is different i.e. 172.57 and 172.56 and 191.203 and 191.234 )
3. Option B is Class A network.( so cant be the answer)
4. Option D is class B network , and its 1st two octet are also same i.e. 128.8 and 128.8 so now no problem to apply above principle to final check.

Can I think like this before applying principle ? ( just to save time )

• No, the answer using "the principle" is not D. It's odd to speak of doing it "directly" a different way - the way you describe as "the principle" is simple and direct. (Also, using 255.255.31.0 as a "subnet mask" makes it a confusing question - subnet masks should not have any gaps of unset bits between the most significant bit and the right-most set bit). – nobody Oct 6 '14 at 17:32

## 1 Answer

No. You can't use your shortcut method.

Your rules #2 and #4 are fine, but rules #1 and #3 are not valid. For example, it's possible (and common) to have a local network 10.0.0.x where the subnet mask is 255.255.255.0. Suppose the IP address of a local host is 10.0.0.7. Your rule #3 would suggest that it can't be a match, because 10.x.y.z belongs to a class A network, whereas the subnet mask looks like the mask for a class C. However, that rule leads you to the wrong conclusion. In fact, you can have a network 10.0.0.x with subnet mask 255.255.255.0. It's possible to take a large network (a class A network) and divide it into multiple smaller local area networks, each with a separate subset of the address space of the large network.