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 :)
255.255 , with a default subnet mask of 255.255. 255.0 (or /24 in CIDR). Class C translates to 2,097,152 (221) networks and 254 (28-2) usable addresses per network.
We can use the following formula to calculate the total number of IP addresses within a subnet by the known the amount of host bits in the subnet mask. Using the formula 2H, where H represents the host bit, we get the following results: Class A = 224 = 16,777,216 total IPs. Class B = 216 = 65,536 total IPs.
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."
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With