LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   How can two seemingly different subnets on the same segment talk toeach other? (https://www.linuxquestions.org/questions/linux-networking-3/how-can-two-seemingly-different-subnets-on-the-same-segment-talk-toeach-other-653662/)

jdavis2 07-04-2008 07:14 PM

How can two seemingly different subnets on the same segment talk toeach other?
 
I was in the process of creating a larger subnet on my home network and before I changed the prefix/mask on the last system I noticed that I could still ping and make ssh connections across what I believed to be a different subnet.

I have a mixture of physical and virtual machines in a home network environment (just for fun). Both Linux and Windows systems. I am working with 192.168.1.32/28 and 192.168.1.0/26. I have a DNS server and a DHCP server on 192.168.1.0/26 but the DHCP server is only serving a few addresses in the 192.168.1.32/28 ranges (because I haven't gotten to it yet). However, all of the systems involved right now have a hard coded ip address. The name server is also forwarding ip packets.

I have a system with the address of 192.168.1.44 with a mask 255.255.255.240 broadcast 192.168.1.47. With this system I can access machines on 192.168.1.0/26 with the following addresses 192.168.1.41 and 192.168.1.39 while each of those have a netmask 255.255.255.192 and broadcast of 192.168.1.63.

192.168.1.41 is linux virtual machine(Ubuntu6.04) hosted on a windows system in the 192.168.1.0/26 subnet and 192.168.1.39(Mandrake10.0) is linux physical machine in the same subnet. 192.168.1.44/28(Open Suse10.3) is also a linux physical machine.

Why are these systems talking to each other?

apnicservices 07-04-2008 07:17 PM

Traceroute from one machine to another, your router between the different subnets is probably routing between them.

Mr. C. 07-04-2008 09:35 PM

This works mostly because you have subnetted a subnet, are only using addresses common to both subnets, and have luckily avoided a trap.

Let's show what is happening with your addresses, and why everything seems to work. We'll start with unicast addresses.

All of your networks are 192.168, so let's drop the first two of the four octects. And I'll call your networks NET1 and NET2. Your addresses look like:

Code:

name: network network bits      netmask network bcast ip range
NET1: 1.32/28 nnnnnnnn.nnnnhhhh  255.240  1.32  1.47  1.33 - 1.46
NET2: 1.0 /26 nnnnnnnn.nnhhhhhh  255.192  1.62  1.63  1.1  - 1.62

where n is the network part, and h is the host part.

Quote:

I have a system with the address of 192.168.1.44 with a mask 255.255.255.240 broadcast 192.168.1.47.
Ok, this system is in our NET1.

Quote:

With this system I can access machines on 192.168.1.0/26 with the following addresses 192.168.1.41 and 192.168.1.39 while each of those have a netmask 255.255.255.192 and broadcast of 192.168.1.63.
Ok, these systems are in NET2.

Quote:

192.168.1.41 is linux virtual machine(Ubuntu6.04) hosted on a windows system in the 192.168.1.0/26 subnet and 192.168.1.39(Mandrake10.0) is linux physical machine in the same subnet.
Ok, this system is in NET2.

Quote:

192.168.1.44/28(Open Suse10.3) is also a linux physical machine.
Ok, this system is in NET1.

Quote:

Why are these systems talking to each other?
If you look at the ip range column above, you'll see that NET1 is a subset of NET2; in other words, all addresses in NET1 are in NET2.
You will also notice that all of your addresses (1.44, 1.39, 1.41) are in both NET1 and NET2. Therefore, you just happen to have two overlapping subnets, and just happen to be using only those addresses that are in both subnets. Thus, route processing strips off the network part to perform network packet switching, and all addresses fall within the same route.

Now what about broadcast addresses? Since broadcast addresses don't cross network boundaries (aka: broadcast domains), there is no problem given the IPs you are currently using.

In the chart below, You see that the broadcast bits look identical, with one exception: the 5th bit, which is 16. I've marked that bit with a ?.
Code:

name: bcast  bcast bits
NET1  1.47  1  00101111
            n  nnn?hhhh
NET2  1.63  1  00111111
            n  nnhhhhhh

But, wait! There is a problem. What about host 101111 (47) on NET2? This looks exactly like a broadcast on NET1 ! Thus, all hosts on NET1 will accept and attempt to handle the packet.

So it is only luck (or the well-worked out homework example here!) that allows this to work out.

jdavis2 07-04-2008 11:27 PM

I think I get it now.
 
Quote:

Originally Posted by Mr. C. (Post 3204511)
This works mostly because you have subnetted a subnet, are only using addresses common to both subnets, and have luckily avoided a trap.

So it is only luck (or the well-worked out homework example here!) that allows this to work out.

Okay, 192.168.1.0/28 is a subset of 192.168.1.0/26 so it is almost like they are on the same subnetwork especially while residing on the same segment.

If I am following you correctly, it would not haved worked if I had used the next subnet which would be 192.168.1.64/26 instead of 192.168.1.0/26?

Mr. C. 07-04-2008 11:32 PM

Sounds like you've got it.

jdavis2 07-04-2008 11:42 PM

Thank you! I can see how knowing this will help me avoid other more serious traps in the future. Like in the area of security.


All times are GMT -5. The time now is 03:26 AM.