The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
+15 votes

The subnet mask for a particular network is $$ Which of the following pairs of $\text{IP}$ addresses could belong to this network?

  1. $$ and $$

  2. $$ and $$

  3. $$ and $$

  4. $$ and $$


asked in Computer Networks by Veteran (69k points)
edited by | 4.8k views

Option A is class a Network 

But Why are we not checking Option C?  Because Class B Ip ranges from 128 to 191.

Can Anyone Please clarify this point?

Ip Ranges

because they asked that both ips should be in the same network so in option C the ip is class B so we need 16 bits of network ID and one ip is in 191.203 network and the other ip is in 191.234 network hence they dont belong to the same network

4 Answers

+49 votes
Best answer

A and C are not the answers as the second byte of IP differs and subnet mast has 255 for second byte.

Consider B, (& for bitwise AND) & = (28 = 111002) & = (29 = 111012)
So, we get different subnet numbers

Consider D. & = (129 = 100000012) & = (161 = 101000012)
The subnet number matches. So, D is the answer. 

answered by Veteran (346k points)
edited by
can u please elaborate your answer..i am not able to understand it.
Sir why u have not considered A,C

I dont have clarity with this
The method is simple, if we AND the IP and subnet mask, we should get the same value, for 2 different IPs to belong to the same network. For A andC, it is easy as their second bytes are different and subnet mask for second byte is 255 (all 1's) which won't give same value after AND. ,
Thank U sir
@Arjun Sir Edit Request:-

29's Binary=11101

11111=31's binary
A subnet mask is always the contiguos set of 1's so I think given subnet mask is not a valid subnet mask.Am I right if not correct?
the subnet mask is of class B and the option b is for class A, do we need to check it?

@arjun sir

29 = 111012      NOT 29 = 111112

Subnet bits for the 3rd octet:         00011111 bits for 3rd octet:       00011100 bits for 3rd octet:       00011101 bits for 3rd octet:  10000001 bits for 3rd octet:  10100001

Only for the unmasked bits of the subnet( i.e which are 1's ),  the host IP address bits must be identical for all those hosts which are to be on the same network. Otherwise, they are on different network.

Don't confuse it with longest prefix matching technique used for router packet forwarding. 


conventionally and practically, subnet mask's are taken contigous from left to right, but for framing qsns it can be present anywhere
+3 votes

The subnet  belongs to Class B, since its net id is 255.255 .

So, we can conclude that either option could be (A) or (D).

Now, the question asks that the the IP should be  same network, so, to test that the IP are in same network we check that whether their netwrok address is same, by using AND operation.

IP AND MASK = network address

In case of option A, we can see that when we apply AND operation to first byte of IP and first byte of MASK both the IP will give same, but when we apply AND operation is applied on second byte then both the IP gives different. So, option A is eliminated and hence Option D is selected because both IP has first and second IP as same.



answered by (165 points)
+3 votes
I am solving here through elimination type procedure

The subnet mask 255.255.x.x belongs to class B type(IP address range will be from to so we can eliminate option B

Now we understand A, C, D belongs to class B network.

we will do a bit by bit AND operation of network and subnet mask to find the subnet.

A) and

C) and

D) and

clearly, we see the second octet of option A and C (57,56       203,234      are different.   57 & 255, 56 & 255 will give different values       203 & 255, 234 & 255 will give different values) are different so this implies that they don't belong to the same subnet.

Now we eliminated A B C then option D will be the answer.

still, if you want to check the answer for being safe side then follow below procedure

now for first option D the first two octets are same so you don't need to do  AND with 255 and waste time so now go to the third octet

         129 =1000 0001     161=1010 0001

          31=  0000 11111      31= 0000 11111


                  0000 0001             0000 0001

The third octet of subnets are same(first 2 octets are also same).

still not confident abt D then do fourth octet of network AND with fourth octet subnet mask.

Here anyhow fourth octet of mask is 0 so anything AND with 0 is zero

So the conclusion is, D is the correct answer.

Comments are always welcome!!!


There is no carry in doing AND operation. it is just bit by bit AND.
answered by (145 points)
edited by
–8 votes
ans c)
answered by Boss (5.1k points)

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

33,687 questions
40,230 answers
38,800 users