开发者

problem calculating subnet mask

Question in some competition exam:

The subnet mask for a particular network is 255.255.31.0. Which of the following pairs of IP addressed could belong to this network?

1: 172.57.88.62 & 172.56.87.23
2: 10.35.28.2 & 10.35.29.4
3: 191.203.31.87 & 192.234.31.88
4: 128.8.129.43 & 128.8.161.55

Now I am having a confusion in this question that i have read that 开发者_高级运维a subnet mask is of pattern: 1111 1111. 1111 1111. 1111 1 I mean 1's start from left side but in this subnet mask:

1111 1111. 1111 1111. 0001 1111. 0000 0000

So what is the actual principle behind. please explain. i am totally confused.

Thanks in advance :)


That's a discontiguous subnet mask, which is no longer supported on most routers. The principle is the same: 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.


This type of subnet mask is kind of theoretical rather than practical. We use subnet mask of all 1's from most significant bit and all 0's at the end just to ensure that hosts in a particular subnet gets contiguous IPs. But if we have a subnet like this : 255.255.31.0
We would not be able to allocate contiguous IPs to host in a particular subnet. But still it is a possibility (theoretically). This kind of subnet masks are barely used in practice.
Coming to the question,
The idea to figure out the IPs belonging to same network is same as in the normal subnet mask scenario.
Just take 'AND' of bits of given IPs with subnet mask (needless to say, resultant would be network id)and check which turns out to be the same for the pair.

options-
(a). This is incorrect in the first place.
Net IDs : 172.57.(something).0 and 172.56.(something).0
second octet is different
(b). Net IDs : 10.35.28.0 and 10.35.29.0
This is incorrect since third octet is different.

(c). Net IDs : 191.203.31.0 and 192.234.31.0
Clearly, this is incorrect since second and third octet are different.

(d). This will be answer (Because rest three are incorrect).

let's check it,
128.8.129.43 AND 255.255.31.0 => 128.8.1.0
128.8.161.55 AND 255.255.31.0 => 128.8.1.0
BINGO !
So, network id turns out to be the same in both cases. So, (d) will be answer.


"There are 10 types of people in this world - one who understand ternary, one who don't and others who just thought that this is gonna be a 'binary' joke."


Ans: option (d) Explanation: Here is the question is: Which of the following pair of IP addresses belongs to the given network. Applying a subnet mask to an IP address separates network address from host address.

So you have to find the network-id from the IP address using the given subnet mask. Below shows the example of how to find a network-id from given Subnet mask and IP address

The network bits are represented by the 1's in the subnet mask, and the host bits are represented by 0's. Performing a bitwise logical AND operation on the IP address with the subnet mask produces the network address. For example, applying the Class C subnet mask to our IP address 216.3.128.12 produces the following network address:

IP: 1101 1000 . 0000 0011 . 1000 0000 . 0000 1100 (216.003.128.012) Mask: 1111 1111 . 1111 1111 . 1111 1111 . 0000 0000 (255.255.255.000) ------------------------------------------------------ 1101 1000 . 0000 0011 . 1000 0000 . 0000 0000 (216.003.128.000)

Therefore the network-id is: 216.003.128.000

Hence doing the above for all the options, you will find that option (d) belongs to the same network.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜