LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 03-16-2006, 05:36 AM   #1
Berkut83
Member
 
Registered: Jan 2006
Distribution: red hat enterprise 3.0
Posts: 47

Rep: Reputation: 15
I can't really figure out why these two hosts can ping each other


Hi all, i have a damned doubt about subnet mask

For example i have to hosts with follow addresses connected directly with a simple cable:

A IP 10.124.8.1
A SUBMSK 255.255.252.0

B IP 10.124.11.2
B SUBMSK 255.255.252.0

It is clear that they are in the same subnet. Here below the explanation

A 10.124.8.1

A IP______ 00001010.01111100.000010|00.00000001
A SUBNMSK 11111111.11111111.111111|00.00000000


A SUBNET PORTION 00001010.01111100.00001000.00000000

B 10.124.11.2

B IP______ 00001010.01111100.000010|11.00000010
B SUBNMSK 11111111.11111111.111111|00.00000000


B SUBNET PORTION 00001010.01111100.00001000.00000000


It's clear that this 2 hosts can ping each other because the portions of the subnet are the same in both of them


NOW THE PROBLEM:

how is possible that these 2 hosts below can ping each other???i can't really understand!!
Look at their addresses and subnet masks

A IP 10.124.9.1
A SUBNMSK 255.255.255.0 (notice the third byte 255)

B IP 10.124.9.2
B SUBNMSK 255.255.252.0 (notice the third byte 252)

And now the same procedure:

A 10.124.9.1

A IP______ 00001010.01111100.00001001|.00000001
A SUBNMSK 11111111.11111111.11111111|.00000000


A SUBNET PORTION 00001010.01111100.00001001.00000000

B 10.124.9.2

B IP______ 00001010.01111100.000010|01.00000010
B SUBNMSK 11111111.11111111.111111|00.00000000


B SUBNET PORTION 00001010.01111100.00001000.00000000


As you can see in this case the subnet portions are different. How is possible that they are still able to ping each other? i can't really understand.

Thanks to all

Last edited by Berkut83; 03-16-2006 at 05:40 AM.
 
Old 03-16-2006, 06:11 AM   #2
okmyx
Member
 
Registered: May 2004
Location: Cornwall, UK
Distribution: Ubuntu 8.04
Posts: 464

Rep: Reputation: 31
Probably because there both in the 10.124.9 subnet.

CompA with a third byte of 255 will only be able to see machines in the same subnet.

CompB with a third byte of 252 will able to see all machines in subnet 9 and all other subnets allowed by the 252 netmask (not exactly sure which ones i always get confused at that stage).

Edit: After a little research with a third byte of 252 CompB will see all computers with ips of 10.124.8.1 to 10.124.11.254

Last edited by okmyx; 03-16-2006 at 06:20 AM.
 
Old 03-16-2006, 06:12 AM   #3
marozsas
Senior Member
 
Registered: Dec 2005
Location: Campinas/SP - Brazil
Distribution: SuSE, RHEL, Fedora, Ubuntu
Posts: 1,501
Blog Entries: 2

Rep: Reputation: 68
The A network, 10.124.9.1/255.255.255.0 has ips in the range: 10.124.9.1 to 10.124.9.254.

The B network, 10.124.9.2/255.255.252.0 has ips in the range:
10.124.8.1 to 10.124.11.254

So the A network is a sub space of B (which is larger than A). The A network is part of B address space.

To avoid two networks to talk each other they must have a separated address space.

cheers,
 
Old 03-16-2006, 06:35 AM   #4
asimba
Member
 
Registered: Mar 2005
Location: 127.0.0.0
Distribution: Red Hat / Fedora
Posts: 355

Rep: Reputation: 42
I do know how they are able to ping in any case - since you are using plain/simple network cable - that too directly plugged . Probably I am missing something.
 
Old 03-16-2006, 06:45 AM   #5
Berkut83
Member
 
Registered: Jan 2006
Distribution: red hat enterprise 3.0
Posts: 47

Original Poster
Rep: Reputation: 15
Yes but look at it from bynary view instead from number view

if you look at the line which separe subnet portion from host portion, it's clear that host B has a different subnet portion

so teorically when they control their subnet mask to understand what is subnet in binary form they find that one is on 10.124.9.0 and the other one in 10.124.8.0


And like you have said, the fact that 10.124.8.0/22 include 10.124.9.0, 10.124.10.0, and 10.124.11.0 until 10.124.11.255 is right, but only because 9 is composed by 8 (net id) + 1 (host id), 10 is composed by 8 (net id) + 2 (host id), 11 is composed by 8 (net id) + 2 (host id) + 1 (host id). So basically all these numbers has always 8 as net id. But in my case is very strange because for the host A yes, we have 9, but this 9 is composed by
8 (net id) + 1 (again net id) and not by 8 (net id) + 1 (host id) because the third byte is 255 and not 252.

If both have the third byte set to 252 then the rule of 10.124.8.0 to 10.124.11.255 applies well, but having different byte causes a lot of doubt in my head

I am very confused....

Last edited by Berkut83; 03-16-2006 at 06:51 AM.
 
Old 03-16-2006, 07:27 AM   #6
Berkut83
Member
 
Registered: Jan 2006
Distribution: red hat enterprise 3.0
Posts: 47

Original Poster
Rep: Reputation: 15
**************************
FINALLY I HAVE UNDERSTOOD


Ok guys thanks for the help i have now understood. The truth is that the host completely ignore that a number like 9 can be composed by
a net id portion and by an host id portion

The rule is simple, if both hosts ip exist in both ranges, also if the subnet masks are different, then the hosts can ping each other.

I think that i can call this phenomenon OVERLAPPING, a word already used also to indicate a badly configuration of 2 dhcp serving the same subnet, allowing them to lease same ip range, and causing duplicate ip problem appears.


I have done different tests and this rule applies very well

Thanks all for the help , now the sky in my head is clear again
 
Old 03-16-2006, 07:43 AM   #7
marozsas
Senior Member
 
Registered: Dec 2005
Location: Campinas/SP - Brazil
Distribution: SuSE, RHEL, Fedora, Ubuntu
Posts: 1,501
Blog Entries: 2

Rep: Reputation: 68
routing is the answer.

Oh, I understand your question now.

Well there is nothing wrong with that. I mean, when you ping the google.com, 216.239.37.104, the google's server is getting an ip packet from your valid external ip address, what is in a very different network. And, it answers back to you, and your machine receives a packet from 216.239.37.104 which is, again, in another network you are. There is no checking against the source address, just the destination adddress in the packet matter.

Subneting is used only for routing decision. There is no subnet mask info in the ip packet. Just the source and destination ip addresses.

If a packet with src=10.124.9.1 and dst=10.124.8.1 manage to reach the 10.124.8.1 interface, than the packet is accepted, no matter which is source address.

So, the answer is routing.
What is the routing table in both machines ?
How they are interconnected ?
 
Old 03-16-2006, 09:36 AM   #8
Berkut83
Member
 
Registered: Jan 2006
Distribution: red hat enterprise 3.0
Posts: 47

Original Poster
Rep: Reputation: 15
mhmm no Marozsas the thing you are explaining is correct but it applies to hosts connected by routers. Thanks to routers they can communicate in the right manner even if they are in different subnets

My question is related to 2 hosts connected each other for example with a cross cable


However i clearly understood that the problem i have exposed is related only to LAN where someone try to connect togheter hosts with different subnet masks, but again, just keep in mind the rule:

EVEN WITHOUT A ROUTER, 2 host connected directly can ping each other if their ip addresses are respectively in both range of the 2 subnets where they are, even with a different subnet and subnet masks.
So doing another example (i have already tried it and it works):

host a: 10.124.9.1
255.255.252.0

the subnet where it is connected is 10.124.8.0

host b: 10.124.11.200
255.255.0.0

the subnet where it is connected is 10.124.0.0

NOTE: both hosts connected by hub without any router.

In this case even if the 2 subnets and subnet masks are very different, these 2 hosts can ping each other because the address 10.124.9.1 of host a, exists in the subnet 10.124.0.0/16 where host b is, and viceversa, the address 10.124.11.200 of host b exists in the subnet 10.124.8.0/22 where host a is.


CONCLUSIONS

So concluding, you guys are right, your first posts are right, both Marozsas and Okmyx, and again, this rule seems to applies well



Last edited by Berkut83; 03-16-2006 at 09:39 AM.
 
Old 03-16-2006, 10:57 AM   #9
marozsas
Senior Member
 
Registered: Dec 2005
Location: Campinas/SP - Brazil
Distribution: SuSE, RHEL, Fedora, Ubuntu
Posts: 1,501
Blog Entries: 2

Rep: Reputation: 68
Hi Berkut83,

I still think the reason is another: routing.
The address are in different networks. Without routing is impossible they reach each other.

Quote:
EVEN WITHOUT A ROUTER, 2 host connected directly can ping each other if their ip addresses are respectively in both range of the 2 subnets where they are, even with a different subnet and subnet masks.
Even without a router, 2 host connected directly can ping each other if there is a route (not a router) to the other network.

In the host A (10.124.9.1) if there is a route to B, and in host B, if there is a route to A (10.124.11.200) then both hosts will ping each other, even they are connected by a twisted cable or by a HUB.
To make the things more clear, the above still true if A is something like 10.0.0.1/24 and B is 172.17.0.1/24 - _and_ there is a proper route table in both machines.

What I did:
In host A
Code:
# ifconfig eth0 inet 10.124.9.1 netmask 255.255.255.0
# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
10.124.9.0      0.0.0.0         255.255.255.0   U     0      0        0 eth0
#
In host B
Code:
# ifconfig eth0 inet 10.124.8.1 netmask 255.255.252.0
# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
10.124.8.0      0.0.0.0         255.255.252.0   U     0      0        0 eth0
#
In host A
Code:
# ping 10.124.8.1
connect: Network is unreachable
In host B
Code:
# ping 10.124.9.1
connect: Network is unreachable
This is fine because they are in different subnets.
Now, if I add routing information to host A:

Code:
# route add -net 10.124.8.0 netmask 255.255.252.0 eth0
# ping 10.124.8.1
PING 10.124.8.1 (10.124.8.1) 56(84) bytes of data.
64 bytes from 10.124.8.1: icmp_seq=1 ttl=64 time=4.71 ms
64 bytes from 10.124.8.1: icmp_seq=2 ttl=64 time=0.636 ms

--- 10.124.8.1 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1003ms
rtt min/avg/max/mdev = 0.636/2.675/4.715/2.040 ms
#
Note there is no need to add routing info to host B because B network already have the A's network.

That is my point. They are in different networks and they can ping each other if, and only if, there is routing information to do that.

Try to remove your routing table. I beat you can not get A to ping B or vice-versa anymore.

Last edited by marozsas; 03-16-2006 at 12:06 PM.
 
Old 03-16-2006, 04:22 PM   #10
Darin
Senior Member
 
Registered: Jan 2003
Location: Portland, OR USA
Distribution: Slackware, SLAX, Gentoo, RH/Fedora
Posts: 1,024

Rep: Reputation: 45
What you expected was that the two systems would not ping each other? Assuming they were on the same layer 2 network, both of them think the other is also on it's same IP network as well. The netmask actually defines what that host thinks is local and what it thinks is not local, so:

A IP 10.124.9.1
A NETMASK 255.255.255.0 (notice the third byte 255)
A IP______ 00001010.01111100.00001001|.00000001
A NETMASK 11111111.11111111.11111111|.00000000
A SUBNET PORTION 00001010.01111100.00001001.00000000

B IP 10.124.9.2
B NETMASK 255.255.252.0 (notice the third byte 252)
B IP______ 00001010.01111100.000010|01.00000010
B NETMASK 11111111.11111111.111111|00.00000000
B SUBNET PORTION 00001010.01111100.00001000.00000000

This is what you posted and it is all correct, however when A tries to ping B it looks at B's address and uses *it's* netmask to see if B is local:

A NETMASK 11111111.11111111.11111111|.00000000
B IP______ 00001010.01111100.00001001.00000010
SUBNET PORTION 00001010.01111100.00001001.00000000
(it thinks B is on the same subnet!)

Once it thinks B is on the same IP subnet as it, it will send a direct communication to B without trying to use a router. The same is true for B trying to ping A:

B NETMASK 11111111.11111111.111111|00.00000000
A IP______ 00001010.01111100.00001001.00000001
SUBNET PORTION 00001010.01111100.00001000.00000000
(it thinks A is on the same subnet!)

I hope that clarifies this some.
 
Old 03-17-2006, 04:13 AM   #11
Berkut83
Member
 
Registered: Jan 2006
Distribution: red hat enterprise 3.0
Posts: 47

Original Poster
Rep: Reputation: 15
X MAROZSAS

Sorry to say this marozsas, but i have connected 2 pc directly and yes, they can ping even with that configuration i have post, with no need to insert a router between them.
I have checked and both routing tables are clean, and yes, they can ping, believe it or not, or better, try to take a cross cable and try it yourself,connect 2 machines, they will ping each other, i have simply tried it instead of only say it.

So after tried, if it works, there is no doubt that it's true

Here for you

*********************ROUTING TABLES AND PING TRIES******************


********************************************************************
********************************************************************
FIRST MACHINES WINDOWS XP 10.124.11.200 with 255.255.0.0

NOTE: is italian version, in italian NOTHING is NESSUNO,
_______ELENCO INTERFACCE is INTERFACE LIST and REPLY is RISPOSTA


Microsoft Windows XP [Versione 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.


C:\Documents and Settings\Berkut83>route print 10.124.9.1


Route attive:
Nessuno
Route permanenti:
Nessuno



C:\Documents and Settings\Berkut83>ping 10.124.9.1

Esecuzione di Ping 10.124.9.1 con 32 byte di dati:

Risposta da 10.124.9.1: byte=32 durata<1ms TTL=64
Risposta da 10.124.9.1: byte=32 durata<1ms TTL=64
Risposta da 10.124.9.1: byte=32 durata<1ms TTL=64
Risposta da 10.124.9.1: byte=32 durata<1ms TTL=64

Statistiche Ping per 10.124.9.1:
Pacchetti: Trasmessi = 4, Ricevuti = 4, Persi = 0 (0% persi),
Tempo approssimativo percorsi andata/ritorno in millisecondi:
Minimo = 0ms, Massimo = 0ms, Medio = 0ms

C:\Documents and Settings\Berkut83>


*********************************************************************
*********************************************************************


SECOND MACHINE LINUX RED HAT ENGLISH 10.124.9.1 with 255.255.252.0


Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
10.124.8.0 0.0.0.0 255.255.252.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
10.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 eth0
127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo
0.0.0.0 10.255.255.254 0.0.0.0 UG 0 0 0 eth0

[root@linux network-scripts]# ping 10.124.11.200
PING 10.124.11.200 (10.124.11.200) 56(84) bytes of data.
64 bytes from 10.124.11.200: icmp_seq=0 ttl=128 time=0.132 ms
64 bytes from 10.124.11.200: icmp_seq=1 ttl=128 time=0.114 ms
64 bytes from 10.124.11.200: icmp_seq=2 ttl=128 time=0.108 ms
64 bytes from 10.124.11.200: icmp_seq=3 ttl=128 time=0.106 ms

--- 10.124.11.200 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3012ms
rtt min/avg/max/mdev = 0.106/0.115/0.132/0.010 ms, pipe 2
[root@linux network-scripts]#

*******************************************************************
*******************************************************************


As you can see in routing table there are no router addresses, but simply because there is no phisical router between them



_

Last edited by Berkut83; 03-17-2006 at 04:49 AM.
 
Old 03-17-2006, 06:30 AM   #12
marozsas
Senior Member
 
Registered: Dec 2005
Location: Campinas/SP - Brazil
Distribution: SuSE, RHEL, Fedora, Ubuntu
Posts: 1,501
Blog Entries: 2

Rep: Reputation: 68
Hey Berkut83

But there is a route in RedHat machine to the other network ! From your own data:
Code:
SECOND MACHINE LINUX RED HAT ENGLISH 10.124.9.1 with 255.255.252.0
 
 
 Kernel IP routing table
 Destination Gateway Genmask Flags Metric Ref Use Iface
 10.124.8.0 0.0.0.0 255.255.252.0 U 0 0 0 eth0
You see the routing info in the last line ?

That is I am talking. Without that route, there is no way to one machine communicates with the other one.
 
Old 03-17-2006, 06:43 AM   #13
marozsas
Senior Member
 
Registered: Dec 2005
Location: Campinas/SP - Brazil
Distribution: SuSE, RHEL, Fedora, Ubuntu
Posts: 1,501
Blog Entries: 2

Rep: Reputation: 68
Hey Darin, thanks for join in this discussion,

Darin, I think you are wrong.
If two machines have different networks they can not communicate which other without a router (or a route). There is no exception to this very basic rule.

From your own post, it is clear A and B are two distinct networks:

Code:
A SUBNET PORTION 00001010.01111100.00001001.00000000
B SUBNET PORTION 00001010.01111100.00001000.00000000
As you can see in my experiment, They only ping each other after I install a route.

And as you can see in my last post to Berkut83, in fact, there is a route to the another network in the redhat machine, (based on own Berkut83's output) what explains why they ping each other.

I did a experiment to be sure I am not making any mistakes. Review my previous post, please, and tell me if you can find anything wrong with that, ok ?


cheers,
 
Old 03-17-2006, 07:42 AM   #14
Berkut83
Member
 
Registered: Jan 2006
Distribution: red hat enterprise 3.0
Posts: 47

Original Poster
Rep: Reputation: 15
Wink

X MAROZSAS:

No Marozsas, that is the route for ITS network and NOT for XP network which is 10.124.0.0.
So this is NOT the route line it needs, but it is the standard line for the network where simply it is situated, which is 10.124.8.0.
In fact as you can see, is there maybe a valid gateway address to that line 10.124.8.0??? No, as you can see, it is simply 0.0.0.0 which means that linux can reach every machine in that range without using any gateway, in fact 0.0.0.0 is absolutely not a phisical gateway address, because i repeat, there is absolutely NOT a router between these 2 machines. They are connected directly, trust me, i have personally connected them without any router. I don't have any router, i have never bought a router in any computer shop.

Simply, at my home there are no routers! .

If you don't believe me i can do a digital photo showing
that these 2 machines are connected directly with a cross cable
without using a router!!! the cable exit from a network card,
and enter immediately in the other network card

If they ping each other, then they ping each other, no way.

Last edited by Berkut83; 03-17-2006 at 07:57 AM.
 
Old 03-17-2006, 08:59 AM   #15
marozsas
Senior Member
 
Registered: Dec 2005
Location: Campinas/SP - Brazil
Distribution: SuSE, RHEL, Fedora, Ubuntu
Posts: 1,501
Blog Entries: 2

Rep: Reputation: 68
Hey guys, I'm sorry but I am lost here.

When I setup one machine as 10.124.8.1/255.255.252.0 and other as 10.124.9.1/255.255.255.0 they was not able to ping each other, as expected, because they are in differente networks. It just happened after I add a route to the other network.

I redo the experiment this morning but now, I setup the first as 10.124.9.2/255.255.252.0, and for my surprise, it can ping 10.124.9.1/255.255.255.0 even they are in different networks !

What surprised me is the addresses 10.124.9.2/255.255.252.0 and 10.124.8.1/255.255.252.0 are in the same network, and them, does not matter which address I pick in the range 10.124.8.1 to 10.124.11.254. But obviously, something is different, but it escapes me.
An address at the end of range, e.g. 10.124.11.254, can not ping 10.124.9.1 too, as expected.

So, there is a exception for that network rule which says that a machine can connect directly to other only if they have the same network address ? Here we have a situation where machines in different networks can ping each other, since both are in the overlap address space ?

never heard about. In my opinion this is a bug.

Anyway, this was a good thread,
Nice to talk with all of you,
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't ping localhost (/etc/hosts and DNS are OK) Mr. Gone Linux - Networking 9 10-16-2004 03:05 PM
dhcp client can't ping gateway but can ping other local hosts dirty_forks Linux - Networking 7 10-08-2004 10:54 AM
Quake3 Server, always 999 ping, can't figure it out stormblast Linux - Games 0 08-15-2004 01:10 PM
Cannot ping internet hosts nikhiljosh Linux - General 3 12-10-2003 09:43 AM
RH 7.2 - Can't ping other hosts spato Linux - Networking 8 05-04-2002 05:19 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 12:07 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration