6

This may be a dumb question. Actually I'm sure of it, but i'd like a thorough explanation for it so i can wrap my head around it

consider a switch with two (or more) connected devices, with similar IP addresses but different subnet MASKS. No gateways/routers/vlans. Pure layer 2.

A: 1.1.1.1/24 (255.255.255.0)

B: 1.1.1.2/22 (255.255.252.0)

C: 1.1.1.3/21 (255.255.248.0)

(assume only the digits in the last octet of the IP address change. all IP addresses are "/24" ip addresses (10.3.2.x)

How can A and B (and/or C) communicate? notice the subnet masks are /24, /22, /21, but the IP addresses themselves could be said to follow the /24 paradigm (only the last octet is different per IP address)

is the subnet mask irrelevant in this case?

what effect is had on the broadcast domains?

any other effects? UDP vs TCP?

4
  • 1
    Classful routing isn't a thing anymore Jul 9, 2015 at 12:02
  • 1
    Did you intend for host B to have an IP address of 20.3.2.2 or 10.3.2.2? Based on context, I would expect the latter, but the answer would be entirely different based on which this is.
    – YLearn
    Jul 9, 2015 at 13:48
  • dangit. yes. both ip addresses are 10.3.2.x. i hope i didn't screw up all the answers
    – goofology
    Jul 9, 2015 at 16:49
  • I have modified the question to refer to 1.1.1.x ip addresses for clarity and to avoid confusion. (ignoring the fact that this is not in the 'private' IP range)
    – goofology
    Jul 9, 2015 at 17:07

6 Answers 6

2

Edit: Re-do the answer as the IP's in the question changed.

Note1: It is WRONG to route different subnet masks in the same network/vlan this is just a explanations as to why it work's in certain cases for certain specific IP's.

Note2: Even if the subnets provided were in different vlans, it would be a Broken configuration as the subnet's overlap

IP routing on a host is configured with three pieces of information.

  1. IP Address
  2. Mask
  3. Gateway.

The Mask splits the IP into a upper and lower half (In binary format). The first half (where the mask is all ones) is the network and the second half is the host.

All IP's in the same network IP/mask can talk to each other directly, if the network portion does not match the Gateway is used to router the packets.

A: 1.1.1.1/24 (255.255.255.0) Network 1.1.1.0 Host 0.0.0.1 (HostRange 0.0.0.1-0.0.0.254) IpRange 1.1.1.1 - 1.1.1.254 (Excluding network and broadcast)

B: 1.1.1.2/22 (255.255.252.0) Network 1.1.0.0 Host 0.0.1.2 (HostRange 0.0.0.1-0.0.3.254) IpRange 1.1.0.1 - 1.1.3.254 (Excluding network and broadcast)

C: 1.1.1.3/21 (255.255.248.0) Network 1.1.0.0 Host 0.0.1.3 (HostRange 0.0.0.1-0.0.7.254) IpRange 1.1.0.1 - 1.1.7.254 (Excluding network and broadcast)

The mask is a binary mask, all ones and then all zeros, total length for IPv4 is 8x4=32 bit.

Answer: If you have a host1 talking to a Host2 and according to host 1, host 2 is in the same Network(IP/mask) it will send packets directly.

In the provided example, although misconfiguration the Network portion of ip A, B and C matches.

This would break down if i chose in the same subnets different IP's, they would not be able to ping each other with out the assistance of a L3/Router to route between the subnets.

AA. 1.1.1.1/24

BB. 1.1.2.2/22

CC. 1.1.7.1/21

1
  • I did make a typing error, apologies. I have corrected the question and clarified the scope (flat layer 2 network). I believe your A/B explanation still applies, but i don't exactly understand. I suppose i need to look at the binary evaluation of the IP/subnet mask to determine the network/host. My question mainly concerns how/why A and B would (or would not) be able to communicate.
    – goofology
    Jul 9, 2015 at 16:55
6

For reference:

Host A: 1.1.1.1/24 (subnet 1.1.1.0/24, range 1.1.1.0 - 1.1.1.255)

Host B: 1.1.1.2/22 (subnet 1.1.0.0/22, range 1.1.0.0 - 1.1.3.255)

Host C: 1.1.1.3/21 (subnet 1.1.0.0/21, range 1.1.0.0 - 1.1.7.255)

Example communication: Host A to Host B

In this example, Host A and Host B have never communicated with each other nor the switch between them. Also, Host A is female and Host B is male so I can avoid ambiguous use of the pronoun "it".

  1. Host A (1.1.1.1) determines she needs to talk to 1.1.1.2.
  2. Host A determines that the destination IP (1.1.1.2) is in the same subnet range as Host A, so this whole communication should only need to happen over Layer 2. If the destination IP weren't in Host A's subnet, Host A would send the packet to her default gateway to be routed.
  3. Host A sends an ARP request asking "Who has 1.1.1.2? Tell 1.1.1.1."
  4. The switch broadcasts Host A's ARP request. The switch doesn't care about IP addresses or subnet masks.
  5. Host B sees the ARP request, knows that he has 1.1.1.2, and sends an ARP response that includes his MAC address. Something like "I have 1.1.1.2, my MAC address is BB".
    ARP requests do not include any data about subnet masks, so there is no way for Host B (or A) to know that the other host has a different subnet mask at this point.
  6. Host A now has Host B's MAC address, and will send a layer 2 frame with her MAC address as the source and his MAC as the destination, which the switch will happily pass along.
  7. Future communication between Host A and Host B will be through the switch via MAC addresses. Host B will likely also do an ARP request to associate Host A's MAC with her IP address.

Side note: I skipped a few details about the ARP request process that aren't super relevant here.


Communication between A and C, as well as B and C, should follow the same kind of process.

In short, because (1) the hosts are on the same L2 segment and (2) they all see each other's IP addresses as being in their own subnet, they will communicate through the switch using MAC addresses as if they were in the same subnet, initially making ARP requests to match up the other devices' IPs.

I also agree with the other answers that say this is a bad configuration. If another host is added to the switch and has an address outside of Host A's subnet but inside B and C's subnets, it could take some time to troubleshoot.

1
  • Thanks. I think I just needed clarification of the now totally obvious fact that 255 is included in 252 which is itself included in 248, etc. not sure why I made that particular example harder to understand for myself than any other subnetting excercise. I knew it was a dumb question but I got some clear answers that pointed out the obvious.
    – goofology
    Jul 9, 2015 at 21:48
0

"but the IP addresses could be said to follow the /24 paradigm.". That is the irrelevant statement. In Classless Inter-Domain Routing, as is common these days, the actual values in the IPv4 address are irrelevant for network address determination. Only the netmask is relevant to determine what part of the IP address is the network address and what part is the host address.

So

  • A: 10.3.2.1/24 is on net 10.3.2.0
  • B: 20.3.2.2/22 is on net 20.3.0.0

As you state these are on the same switch, but you don't specify a VLAN assignment or otherwise, so I assume the broadcast domain is still the whole network. What you basically have is an overlay network, in which two IP networks share the same broadcast domain. In itself not a problem, but does cause additional traffic. Any host on IP network A that wants to communicate with a host on IP network B has to go through the router between the two (yes, this router must have multiple addresses on the same network interface, one for network A and one for network B). Even though they are in the same broadcast domain, the IP addressing prevents them from communicating directly.

1
  • I apologize - I specified the wrong IP address for host B. both ip addresses are 10.3.2.x. sorry i screwed that up. flat network, no router. let me know if this changes your response in any way.
    – goofology
    Jul 9, 2015 at 16:51
0

Why? Because subnet math.

1.1/24 can talk to anything in 1.0/24 because the mask says they are "local" ("on the wire"). If 1.1/24 tried to talk to 2.1/23, it fails: "2" is outside the 1.0/24 range; and fwiw, "1" is outside 2.0/23's range. 3.1/22 would be able to send to 1.1/24 -- /22 covers 0-3 -- but 1.1/24 wouldn't be able to answer.

2
  • I don't think you understood the question. The ONLY part of the IP that changes is the last digit.
    – goofology
    Jul 9, 2015 at 20:52
  • And you don't understand the role netmask plays.
    – Ricky
    Jul 9, 2015 at 20:53
0

It might definitely work. But the problem that arises when you are not configuring static IP's , then in that case /24 can assign 1.1.1.1, 1.1.1.2 as well and /23 can also assign the same - especially if you have same range in DNS/DHCP. so there could be potential IP conflicts that could arise

0

A and B should be able to communicate, because both A's host portion and B's host portion are within the subnets of each, where the original post showed A with a /24 and B with a /30...while C had a /29. C cannot talk to B, since the C host's. 3 would be a broadcast address (not a valid host) in B's subnet masking. Basically, based on non-overlapping valid host bits:

  • A and B could talk
  • A and C could talk
  • B and C cannot talk, because C's. 3 is a broadcast address in B's subnet 0, where .1 and .2 are valid hosts, but .3 is a broadcast address in B's subnet 0, where .4 is its next subnet---which has only. 5 and .6 as valid hosts, with .7 as the broadcast address, and with .8 as the next 'block' or subnet. I have basically the same question as goofology, and would like to know definitively if A and B could talk as they are.
5
  • Actually, all three, if masked with the longest mask (255.255.255.0), are in the same network (1.1.1.0/24). That means A, B, and C can communicate without trying to send traffic to their configured gateways.
    – Ron Maupin
    Dec 23, 2016 at 4:56
  • That's the obvious, and was not the original question...i.e., of course there'd be no issue if they all used a /24
    – ajoos
    Dec 27, 2016 at 6:41
  • The original question (as I understood it) was: can these hosts with disparate masks still communicate, as long as there's no conflicts (no overlaps) with their host bits
    – ajoos
    Dec 27, 2016 at 6:54
  • 'communicate' = i.e. point-to-point, as if on the same subnet
    – ajoos
    Dec 27, 2016 at 7:07
  • "How can A and B (and/or C) communicate? notice the subnet masks are /24, /22, /21, but the IP addresses themselves could be said to follow the /24 paradigm (only the last octet is different per IP address)" Also, C is not a broadcast address of either A or B. There would be no problem with any of the three communicating with any of the others.
    – Ron Maupin
    Dec 27, 2016 at 15:18

Your Answer

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

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