2.4k views

Consider three machines M, N, and P with IP addresses $100.10.5.2, \: 100.10.5.5$, and $100.10.5.6$ respectively. The subnet mask is set to $255.255.255.252$ for all the three machines. Which one of the following is true?

1. M, N, and P all belong to the same subnet
2. Only M and N belong to the same subnet
3. Only N and P belong to the same subnet
4. M, N, and P belong to three different subnets

edited | 2.4k views

First derive the network address of those machines, then we can decide !

Finding network address for a M/C :- Perform Bitwise AND between m/c address and given subnet mask.

Subnet Mask: keep $1$'s in Network part $+$ subnet part and keep $0$'s in Host part.

$255.255.255.252 = 11111111.11111111.11111111.11111100$
$\implies 24( \text{from first 3 octets} ) + 6 ( \text{ in last octet })$
$\quad = 30 \text{bits in Network+ subnet portion and last 2 bits represent the Host part}.$

Subnet Mask $= 255.255.255.252$ and $M = 100.10.5.2$ but keep all zero's in HOST part !

$\begin{array}{|l|l|l|l|} \hline 100 = 01100100 & 10 = 00001010 & 5 = 00000101 & 2 = 000000 \color{red}{00} \\ \hline 255 = 11111111 & 255 = 11111111 & 255 = 11111111 & 252 = 11111100 \\ \hline 100 & 10 & 5 & 0 \\ \hline \end{array}$

Subnet Mask $= 255.255.255.252$ and $N = 100.10.5.5$ but keep all zero's in HOST part !

$\begin{array}{|l|l|l|l|} \hline 100 = 01100100 & 10 = 00001010 & 5 = 00000101 & 5 = 000001 \color{red}{00} \\ \hline 255 = 11111111 & 255 = 11111111 & 255 = 11111111 & 252 = 11111100 \\ \hline 100 & 10 & 5 & 4 \\ \hline \end{array}$

Subnet Mask $= 255.255.255.252$ and $P = 100.10.5.6$ but keep all zero's in HOST part !

$\begin{array}{|l|l|l|l|} \hline 100 = 01100100 & 10 = 00001010 & 5 = 00000101 & 6 = 000001\color{red}{00} \\ \hline 255 = 11111111 & 255 = 11111111 & 255 = 11111111 & 252 = 11111100 \\ \hline 100 & 10 & 5 & 4 \\ \hline \end{array}$

$\therefore$ only $N$ and $P$ are belong to same network $(100.10.5.4/30)$
by Veteran (65.8k points)
edited
+1

why to keep zeroes in the host ID  part?

+1
@Shaik Masthan
00000100 = 4 not 1
+1 vote
M: 100.10.5.2 , N: 100.10.5.5 , p: 100.10.5.6

SM = 255.255.255.252 = 255.255.255.11111100 (only express lasy byte into binary form bcz first 3 byte already all 1)

Now Bitwise end of every Ip (M,N,P) to SM . It will give us Network id (NID) of each .

for M it NID gives : 100.10.5.0

for N it NID gives : 100.10.5.4

for P it NID gives : 100.10.5.4

So, we can say that N,P belongs to same subnet

And subnet is : (100.10.5.4/30)
by Junior (987 points)
If two host belong to same network then their subnet id should be same . Subnet id can be obtained using subnet mask .Take a IP address of a host and perform Bitwise AND operation with subnet mask results subnet id.
Ip address of M IPm: 194.56.10.2
Ip address of N IPn : 194.56.10.5
Ip address of P IPp: 194.56.10.6
Subnet id of M sidm = SM        11111111.11111111.11111111.11111100                                                                                        Bitwise AND                                                                                                                                                                                        IPm                                           11000010.00111000.00001010.00000010                                                                        ____________________________________________________________________
=      11000010.00111000.00001010.00000000
=     194.56.10.0

Subnet id of N= SM             11111111.11111111.11111111.11111100                                                                                             Bitwise AND                                                                                                                                                                                                          IPn                   11000010.00111000.00001010.00000101                     ___________________________________________________________________                                                                                                              = 11000010.00111000.00001010.0000.100                                                                                                                                       =194.56.10.4

Subnet id of P= SM             11111111.11111111.11111111.11111100                                                                                              Bitwise AND                                                                                                                                                                                                     IPp                          11000010.00111000.00001010.00000110               __________________________________________________________________________ .                                                                                             = 11000010.00111000.00001010.00000100
= 194.56.10.4
Sid of N = Sid of P
Hence N and P are host of same network

by Loyal (5.4k points)

This is what I think:

Firstly, the technique is, do bitwise AND with subnet- the network ids given, those who return the same values are in the same subnet.

The parts of the subnet which are 255 will spit out what we give them, they are all 1's so we already know first three octets after multiplication for all three network IDs. They will be the same.

The last octet of the subnet, 252 only matters. Break it to get the binary - 128+64+32+16+8+4 = 11111100. Doing bitwise AND with this binary number will spit out same nos till 6th-bit rest will be eaten by 0's.

The last octets of net ids are -  2-> 000000'10,     5-> 000001'01,      6-> 000001'10  (The ' symbol shows how far the bits survive)

So for 5 and 6 same bit pattern survives, basically, ANDing 252 with 2 gives 0, with 5 gives 4, with 6 gives 4.

As 5 and 6 return same values, they are in the same subnet.

by Active (1.1k points)