2

Can we have exactly same IP addresses with different CIDR notations? Example:

194.24.0.20/20
194.24.0.20/21
194.24.0.20/16
194.24.0.20/24
194.24.0.20/29
194.24.0.20/15
And so on...

How will it effect routing?

3
  • If you're talking about two interfaces with subnets above on the same device, it depends on vendor. Though you sure can have two same subnets with different mask in your network. In routing longest match always wins. E. g. if destination is 192.24.0.1, route to 192.24.0.0/21 will always be used while exists.
    – ar_
    May 6, 2017 at 13:01
  • In your example you have network addresses not host addresses. Your networks are subnets of the /16
    – Ron Trunk
    May 6, 2017 at 13:12
  • 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 and accept your own answer.
    – Ron Maupin
    Feb 19, 2018 at 4:03

3 Answers 3

2

Subnets are for routing tables for longest prefix match. But an IP packet in itself has no notion of subnets. so you cannot assign same IP addresses with different subnets.

1

What you seem to be missing is that when you mask those addresses with your different network masks, they all arrive at the same network address: 194.24.0.0. An IPv4 address is simply a 32-bit binary number. CIDR notation gives you the mask length. When you mask (logical AND) the address and mask, you get the network address. See the previous question, How do you calculate the prefix, network, subnet, and host numbers? and its excellent answer for more details.

You cannot assign overlapping network addresses to router interfaces because the router would have no way to know to which interface it should send traffic destined for that network. You can, however, have multiple routes to a network with different mask lengths in a routing table. The router will look at the mask length to determine to which interface it should send traffic destined for that network. The routing table entry with the longest mask length wins. Based on what you have listed in your question, that would be 194.24.0.0/29.

1

It's always the same IP address, just in varying subnets (all overlapping, inevitably):

194.24.0.20/15 - part of 194.24.0.0 to 194.25.255.255
194.24.0.20/16 - part of 194.24.0.0 to 194.24.255.255 (subnet of above)
194.24.0.20/20 - part of 194.24.0.0 to 194.24.15.255 (subnet of above)
194.24.0.20/21 - part of 194.24.0.0 to 194.24.7.255 (subnet of above)
194.24.0.20/24 - part of 194.24.0.0 to 194.24.0.255 (subnet of above)
194.24.0.20/29 - part of 194.24.0.16 to 194.24.0.23 (subnet of above)

So essentially: no, you can't use the same address for different hosts (if they're connected).

The netmask defines the size of the subnet that's directly connected. This is the range of destination IP addresses that can be talked to directly on a common layer 2 connection (e.g. Ethernet). Destination adresses outside this range require the use of a router.

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.