What happens Same IP Range different subnet mask

0

I had this question posed to me the other day and it is one of those curiosity questions that you may have asked before or perhaps had a situation that presented itself that gave cause to thinking about this question.  What happens same ip range different subnet mask?  And more accurately, what if you have (2) ip addresses that overlap each other or would in one of the subnets?  Will the same router be able to service and ping both as well as carry pings for both?  Well, let’s see.

What happens Same IP Range different subnet mask

Let’s quickly go over the setup which I thrown into Packet Tracer as a quick test config.  So let’s say that the first IP address, 192.168.0.2 has a subnet mask of 255.255.255.0.  The other IP address is 192.168.1.2 and has a subnet mask of 255.255.254.0.

The IP 192.168.0.2 would fall in the range of the subnet configured on the 192.168.1.2 address.  Would it be able to ping the other IP?  Also, would the same router have problems routing traffic between those two hosts?

Notice below the different IP addresses as well as the different subnet masks.

PC1

diffsub02 What happens Same IP Range different subnet mask

PC2

diffsub03 What happens Same IP Range different subnet mask

Router

diffsub04 What happens Same IP Range different subnet mask

What happens?

When the IPs and subnet masks are configured as above, both IPs will be able to ping the router IP and the router will be able to correctly return traffic back to both hosts as the IP and subnet on the router spans both IP ranges and is a summary route of sorts for both.

As you can see below, the first PC configured with the /24 subnet is able to ping the router and get pings back successfully.

diffsub05 What happens Same IP Range different subnet mask

Also, the second PC configured with the /23 subnet is also able to ping and get pings back successfully from the router.

diffsub06 What happens Same IP Range different subnet mask

What doesn’t work

One thing to keep in mind is that this only works because we are using different IPs configured on the PCs.  If we tried to assign the same IP address to both PCs even though the subnets are different, the traffic would not know how to get back to the proper PC that is configured.

Thoughts

So while in practice, this IP addressing works with the different subnets, and could even be used to segment traffic to some degree with one router, this is less than ideal because of the issue of duplicate IP addresses.  If the same IP address is purposely or inadvertently configured on either subnet, the communication to both will be broken.