problem calculating subnet mask
Asked Answered
V

3

9

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 :)

Vitale answered 15/4, 2011 at 3:30 Comment(3)
That is not a valid subnet mask. Consequently, it is hard to know precisely what the test author was trying to assess.Faultfinder
But i can't doubt on its accuracy bcoz this question was in ISRO exam So how could i?Vitale
this is a question asked in GATE 2004 :)Carce
B
15

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.

Bifilar answered 15/4, 2011 at 3:39 Comment(5)
I'm not familiar with that. Were discontiguous subnet masks ever supported?Faultfinder
@Rob, discontiguous subnet masks are still supported on some network access control devices for features like ACLs. (Sometimes, notably on Cisco routers, the subnet masks are written inverted, in this case, so you'll see 0.0.0.255, for example, to mean a /24)Classless
Just to add a little more info to Mike' comment, the inverted subnet mask is called a wildcard maskWaft
Just to clarify.... A subnet mask must be contiguous. This has been the rule for subneting since 1991 (see RFC1219). NO VENDOR supports discontiguous subnet masks. ACLs on Cisco Routers and switches (not ASA firewalls) use wildcard masks. Wildcard masks ARE NOT inverted subnet masks! However, most of the time when useing wildcard masks they are created by inverting the subnet mask. The key to wildcard masks however is that they do not follow the contiguous rule. Which can be very powerful when used to test for things inside an ACL.Isotope
For example. Let say you have a network using the sceme 10.B.V.0/24. Where B = Building and V = VLAN. In each subnet the default gateway is the last address, .254. Let's also say that in the large campus network you have 10 building with about 100 VLANs in each building. If you were to create an ACL to permit traffic from the IP address of the default gateway from each VLAN, using contiguous masks, would result in a 1000 line ACL. However with a discontiguous mask, the ACL is 1 line. access-list 1 permit 10.0.0.254 0.255.255.0 This wildcard mask is only matching on the 10 & 254.Isotope
E
2

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."

Exceed answered 5/2, 2015 at 9:51 Comment(0)
S
0

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.

Subtropics answered 23/5, 2014 at 12:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.