# 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). – Andrew Medico Oct 6 '14 at 17:32