System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

can ping ip_address but can not ping hostname

can ping ip_address but can not ping hostname

Hi all,

I am facing problem to ping host name. I have attached my hosts file and nsswitch.conf file. please help. I can not even ftp.

Rgds,
shovon
9 REPLIES
IT_2007
Honored Contributor

Re: can ping ip_address but can not ping hostname

You have to put fully qualified name in /etc/hosts file like

192.168.2.242 warid01.domain.com warid01

and change nsswitch.conf like

hosts files[NOTFOUND=continue] dns
KapilRaj
Honored Contributor

Re: can ping ip_address but can not ping hostname

I think the hosts file is not correct. you have typed in the same name twise. Infact, the second argument is normally an alias i.e.

192.168.0.1 kapilraj kaps

Where "kapilraj" is the actual name of the machine and "kaps" an alias. So, give it a try removing the duplicate entry in arguments. I don't have a box right infront of me else i could have tested it.

i.e change ur hosts file as follows,

127.0.0.1 localhost loopback
192.168.2.242 warid01

Regds,

Kaps
Nothing is impossible
KapilRaj
Honored Contributor

Re: can ping ip_address but can not ping hostname

btw srini, it is not on of the best practice to use FQDNs in hosts file.
Nothing is impossible
nanan
Trusted Contributor

Re: can ping ip_address but can not ping hostname

change nsswitch.conf

nanan
Trusted Contributor

Re: can ping ip_address but can not ping hostname

change nsswitch.conf

hosts: files [NOTFOUND=continue] dns
Golam Siddik
Occasional Contributor

Re: can ping ip_address but can not ping hostname

Hi all,

As you said I have to modify in the host file like following pattern-

127.0.0.1 localhost loopback
192.168.2.242 warid01

I did it before but the result is same. Anyway I am changing it again. For the nsswitch file you recommended as under-

hosts: files [NOTFOUND=continue] dns

I need to know what would be this second word files? Will it be replaced by fileName/path or it would be just 'files'?

Please help.

Rgds,
shovon
V.Manoharan
Valued Contributor

Re: can ping ip_address but can not ping hostname

Hi Mazharul,
could you please check the basics.

1. type hostname and check the what hostname set for the host. similary check the ip configuration by ifconfig .

2. try check with nslookup and nslookup

3. try changing nsswitch.conf
hosts: files [NOTFOUND=continue] dns

4. just try ping by name & Ip by moving the /etc/resolve.conf /etc/resolve.old. if not fruit result bring it back to original.

5. If all fails try one time reconfiguring the Network card via SAM.

Thanks and regards
V.Manoharan
Manish Shrestha
Occasional Visitor

Re: can ping ip_address but can not ping hostname

Hello,

You have must have configured the nsswitch.conf file incorrectly. It should contain the line:
hosts: files dns

You can view my article at http://www.melectrosoft.com/Linux/Administration/problem-ping-command-linux

Thank you
Manish Shrestha
Rita C Workman
Honored Contributor

Re: can ping ip_address but can not ping hostname

Morning,

The nsswitch.conf should read as:
hosts: files [NOTFOUND=continue] dns

Your /etc/hosts format should look similar to:
IP

Your alias can be a shortened version of the name or whatever you want, it's fine!

Run nslookup commands:
nslookup
nslookup
nslookup

Check the results - do they all match and find the same thing? And what found it, was it your /etc/hosts file or was it DNS?

You need to ensure you get the same results doing these reverse lookups - you need same results for /etc/hosts and DNS. To check DNS:
nslookup
nslookup

Hope this helps,
Regards,
Rita