LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 10-26-2004, 02:38 AM   #1
ElectroLinux
Member
 
Registered: Feb 2004
Posts: 74

Rep: Reputation: 15
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
 
Old 10-26-2004, 03:13 AM   #2
phantompgr
Member
 
Registered: Sep 2002
Location: South Wales, UK
Distribution: Fedora Core & Mandrake
Posts: 83

Rep: Reputation: 15
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
 
Old 10-26-2004, 03:21 AM   #3
ElectroLinux
Member
 
Registered: Feb 2004
Posts: 74

Original Poster
Rep: Reputation: 15
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 the server itself by ip or hostname h_h_q Linux - General 1 01-12-2005 01:24 AM
windows 98 m/c ping to ip address of red hat server but fails to ping hostname ravilohot Linux - Networking 2 09-07-2004 04:57 AM
Unable to ping hostname? robertmarkbram Linux - General 2 11-28-2003 12:06 AM
Can ping by IP but not by hostname gillesdutertre Linux - Networking 8 09-01-2003 07:59 AM
can ping by IP but not by hostname al contado Linux - Networking 6 03-16-2003 03:06 AM


All times are GMT -5. The time now is 08:41 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration