LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Ping or SSh by hostname (https://www.linuxquestions.org/questions/linux-newbie-8/ping-or-ssh-by-hostname-247371/)

ElectroLinux 10-26-2004 02:38 AM

Ping or SSh by hostname
 
I'm trying to ping my linux box by hostname rather than ip. I can ping and ssh into it by ip.

I've searched to forum and found that i just need to add it to my /etc/hosts file. I've done that.

# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 mylinux localhost.localdomain localhost
192.168.1.120 mylinux


I thought this would solve my problem, but I still can't ping or ssh into it. I'm using putty to ssh in and windows cmd to ping.

I'm able to ping mylinux and ping localhost. Is there something wrong with the first uncommented line?

Any suggestions?

TIA

phantompgr 10-26-2004 03:13 AM

I may have misunderstood you so please disregard if this is the case....

You have two boxes, one running Windows and the other running linux?

In order to ping or ssh by hostname from the Windows box, you will need to place the line <IP ADDR> mylinux in the Windows host file as this is what is being checked by the client. The client is responsible for translating hostnames into IP addresses either through hostfiles, DNS, NETBIOS etc... The Windows hostfile is located in C:\WINDOWS\system32\drivers\etc.

As regards your hostfile on your linux box, you should remove the name "mylinux" from the localhost line as this will cause confusion for the box when trying to detect its own ip. For instance, if you ping mylinux on mylinux then the localhost ipaddress will be returned and not the ip address of your network card. This could impact any services you are trying to run. Of course, I could be miles off base on this because I have never tried to see whether it makes any difference or not. I have just never allocated 127.0.0.1 a hostname other than localhost.

Regards

The Phantom

ElectroLinux 10-26-2004 03:21 AM

Thanks phantompgr!

Adding the hostname and ip to the hosts file worked. I took out the hostname in the localhost line just to be safe.

thanks again.


All times are GMT -5. The time now is 05:15 AM.