4

I was just wondering why Packet Tracer allows 2 end devices to ping each other even though they're specced with 2 different subnet masks? am i missing something here? i.e.

PC1: 192.168.1.10/24 PC2: 192.168.1.20/16

Any help would be much appreciated! Cheers

2
  • You should not do that IMHO, even if it just works. Dec 7, 2015 at 16:06
  • Did any answer help you? If so, you should accept the answer so that the question doesn't keep popping up forever, looking for an answer. Alternatively, you can provide your own answer and accept it.
    – Ron Maupin
    Aug 7, 2017 at 16:00

3 Answers 3

2

The purpose of the Subnet Mask is to determine whether the host you are trying to speak to is on your network or on a foreign network.

If the other host is on your network, the sending host is going to send the data directly to the other host.

If the other host is on a foreign network, the sending host is going to send the data to its default gateway.

In your example:

PC1: 192.168.1.10/24 PC2: 192.168.1.20/16

PC1 is configured as a /24, which means it thinks everything in this range is on the local network: 192.168.1.0 - 192.168.1.255. This range includes PC2's IP address, and therefore PC1 considers PC2 to be on its local network.

PC2 is configured as a /16, which means it thinks everything in this range is on the local network: 192.168.0.0 - 192.168.255.255. This range includes PC1's IP address, and therefore PC2 considers PC1 to be on its local network.

Since they both think the other is on the local network, they both follow the rules to communicate with another host on the local network. The fact that their masks are not identical ends up being irrelevant.


That said, as Xavier Nicollet pointed out in the comments... just because it works, doesn't mean it's a good idea. This should be avoided when possible.

Disclaimer: The Youtube video links above are my own creation, I am providing them to the reader to show additional context about hosts communicating on the same networks and foreign networks

1
  • One minor nit: the sending host is going to send the data to it's default gateway. It could be another gateway instead of the default.
    – Ron Trunk
    Aug 6, 2021 at 20:52
1

The two host acan ping each other because they are on the same subnet, /16 can contains host located on /24, that is the reason.

1

Those two devices are in the same subnet. When you mask the addreses with the longest mask, they have the same subnet:

192.168.1.10 AND 255.255.255.0 = 192.168.1.0
192.168.1.20 AND 255.255.255.0 = 192.168.1.0

If, for instance, the second IP address was 192.168.2.20, it would not work since you would be on two different networks from the perspective of the first one, and it would try to send to its configured gateway instead of the other host:

192.168.1.10 AND 255.255.255.0 = 192.168.1.0
192.168.2.20 AND 255.255.255.0 = 192.168.2.0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.