Subnet Communication – Different Subnet Masks with IP Address

subnet

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?

Best Answer

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