LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Who is ping talking to? (https://www.linuxquestions.org/questions/slackware-14/who-is-ping-talking-to-4175450488/)

stf92 02-16-2013 09:28 PM

Who is ping talking to?
 
Hi:

I have a LAN consisting of two hosts. Lets call one the server (or remote host) and the other the local host. Both are connected to internet through a router and modem. Running ifconfig in the server I get:
Code:

root@SERVER_HOST:~# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.0.101  netmask 255.255.255.0  broadcast 192.168.0.255
        inet6 fe80::922b:34ff:feb8:78cf  prefixlen 64  scopeid 0x20<link>
        ether 90:2b:34:b8:78:cf  txqueuelen 1000  (Ethernet)
        RX packets 114069  bytes 66498298 (63.4 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 245027  bytes 40631115 (38.7 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 42  base 0x4000 

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 16436
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 0  (Local Loopback)
        RX packets 740  bytes 43884 (42.8 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 740  bytes 43884 (42.8 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

If, in the local host I do 'ping 192.168.0.101', I get:
Code:

................................................
64 bytes from 192.168.0.101: icmp_seq=1 ttl=64 time=1.77 ms
.................................................

That is, the local host is talking to someone. The question is: whom is it talking?

wildwizard 02-16-2013 10:25 PM

Itself

stf92 02-16-2013 10:27 PM

Why's that?

wildwizard 02-16-2013 10:28 PM

Because you told it to.

Do you think this is some sort of error?

stf92 02-16-2013 10:34 PM

In the first code block, you see it says: 'inet 192.168.0.101'. And as I ran ifconfig in the server, it is some IP associated with the server, not with the local host. So when I do ping 192.168.0.101 from the local host, how can I be talking to the the local host? No, I do not say it's an error. I want to know what is 192.168.0.101.

wildwizard 02-16-2013 10:43 PM

Now I'm getting confused.

Try "arp -n" to see what IP addresses are local to a machine, anything that is routed via a router will not appear in this list.

stf92 02-16-2013 10:47 PM

I get
Code:

root@SERVER_HOST:~# arp -n
Address                  HWtype  HWaddress          Flags Mask            Iface
192.168.0.105                    (incomplete)                              eth0
192.168.0.1              ether  a0:f3:c1:59:06:2a  C                    eth0
root@SERVER_HOST:~#


e5150 02-16-2013 10:48 PM

You ran `ifconfig` on the "server", and it says that the server is 192.168.0.101.
Then you ran `ping 192.168.0.101` from the "local host".
So given that both "server" and "local host" are on the same network (192.168.0.0/24), ping is talking to "server", who is 192.168.0.101.

stf92 02-16-2013 10:54 PM

But in /etc/hosts (in the server) I have:
Code:

# For loopbacking.
127.0.0.1                localhost
127.0.0.1                SERVER_HOST.DN1 SERVER_HOST

# End of hosts.

And I do not see 192.168.0.101 in it. Besides, I, the server, am SERVER_HOST.DN1. So why is it not associated to 192.168.0.101 in /etc/hosts?

wildwizard 02-16-2013 11:04 PM

Well your hosts file is broken as it should have the real IP not the loopback one.

Also I smell a VPN here, am I right on that?

e5150 02-16-2013 11:05 PM

/etc/hosts contains whatever you put in it (the defaults that comes with the etc-package only lists 127.0.0.1). Just about all computers see themselves as 127.0.0.1, it's the loopback interface (as you can see in the lo: section of the ifconfig output: "inet 127.0.0.1 netmask 255.0.0.0").
SERVER_HOST sees itself as 127.0.0.1, as does your other computer. It's eth0 with ip 192.168.0.101 on SERVER_HOST that your other computer can connect to SERVER_HOST through.

stf92 02-16-2013 11:08 PM

I wanted to set the hostname and the domainname and could not do it. So I used netconfig and gave it those names. What it did I do not know, but after I ran it, /etc/hosts was as you see it. About VPN, honestly I don't know what it is.

e5150 02-16-2013 11:20 PM

If you used netconfig to configure for the static ip 192.168.0.101 then /etc/hosts should contain a corresponding line. The setting you have seems to be what you get when setting up the network for dhcp with netconfig.

stf92 02-16-2013 11:22 PM

Quote:

Originally Posted by e5150 (Post 4893421)
/etc/hosts contains whatever you put in it (the defaults that comes with the etc-package only lists 127.0.0.1). Just about all computers see themselves as 127.0.0.1, it's the loopback interface (as you can see in the lo: section of the ifconfig output: "inet 127.0.0.1 netmask 255.0.0.0").
SERVER_HOST sees itself as 127.0.0.1, as does your other computer. It's eth0 with ip 192.168.0.101 on SERVER_HOST that your other computer can connect to SERVER_HOST through.

But who should SERVER_HOST.DN1 be for the local host. If I do rcp SERVER_HOST.DN1:some_file some_directory, on the local host (LOCAL_HOST.DN2), rcp must address some IP. What IP is that?

e5150 02-16-2013 11:29 PM

Quote:

Originally Posted by stf92 (Post 4893428)
but who should server_host.dn1 be for the local host. If i do rcp server_host.dn1:some_file some_directory, on the local host (local_host.dn2), rcp must address some ip. What ip is that?

192.168.0.101

stf92 02-16-2013 11:31 PM

Quote:

Originally Posted by e5150 (Post 4893426)
If you used netconfig to configure for the static ip 192.168.0.101 then /etc/hosts should contain a corresponding line. The setting you have seems to be what you get when setting up the network for dhcp with netconfig.

I never gave netconfig any IP. It does not ask for an IP. Honestly, I do not know where 192.168.0.101 came from. I edited /etc/hosts and put

192.168.0.1 SERVER_HOST.DN1 SERVER_HOST

After I booted, this line disappeared. [But I think 0.1 is reserved. Perhaps I should have write 192.168.0.2] Well, I think I'll continue studying networks before I go on with this after all.

stf92 02-16-2013 11:52 PM

Something remarkable happened. I put the line

192.168.0.101 .........

not in the server's /etc/hosts but in the local host's. As a result, when I issued 'slogin SERVER_HOST' from the local host, I was asked for the password. So I had it all wrong!

e5150 02-17-2013 12:07 AM

If netconfig didn't ask for an IP adress, it's probably because you selected DHCP (or maybe networkmanager, I don't know how that one works). In that case SERVER_HOST would ask the router (whose ip probably is 192.168.0.1) for an ip, and SERVER_HOST would be given 192.168.0.101.

Putting "192.168.0.101 SERVER_HOST.DN1 SERVER_HOST" in /etc/hosts at "local host" basically tells "local host" that "whenever I want to talk to SERVER_HOST or SERVER_HOST.DN1 I should address my messages to 192.168.0.101." So that `slogin SERVER_HOST` works after this change was to be expected.
However if you're using DHCP there is no guaranty that SERVER_HOST always will have 192.168.0.101 as its ip.

There was a small discussion some time ago on the merits of static ip + /etc/hosts versus dhcp, might be of interest to you: http://www.linuxquestions.org/questi...ip-4175436549/

stf92 02-17-2013 12:24 AM

I use DHCP because my ISP does not provide static IPs (I think). As to the rest, logging remotely from the server works fine, but doing it from the local host, the system asks for the password, OK, but then it says 'Permission denied. Please try again'.

Yes, I selected DHCP.

e5150 02-17-2013 12:42 AM

Well, it's only the router/modem that talks directly to your ISP (if I've understood your network correctly). The 192.168.0.x addresses are only visible to your computers, and can be set statically (if that is deemed to be desired).

As to the Permission denied, do you have a user with the same user name on SERVER_HOST as the user who is running `slogin SERVER_HOST` on "local host"? (If the user is root, maybe you have disable remote root logins (as you probably should), PermitRootLogin in /etc/ssh/sshd_config? Do you have any entries in /etc/hosts.deny?
/var/log/messages (or /var/log/syslog) on SERVER_HOST might have some information.

stf92 02-17-2013 01:21 AM

When at the local host, I was always as root. Now I tried going to a console (virtual console in the same machine, the local host) where I am a regular user. I ran 'slogin SERVER_HOST' and this time I succeeded. In the server, in the file /etc/ssh/sshd_config I have

PermitRootLogin no

So there, in the local host, I can only remote login if I am a regular user. However from the server I can remotely login (into the local host) as root! So there is no symmetry. One of the machines is boss.


All times are GMT -5. The time now is 01:33 PM.