Operating System - Linux
1754809 Members
3721 Online
108825 Solutions
New Discussion юеВ

System pings an IP address but won't ping a host name

 
MD.IMTEYAZUL HASSAN
Contributor

System pings an IP address but won't ping a host name

I am trying to check the status of network connectivity of the system,System pings an IP address but won't ping a host name.
What is the reason behind this.
5 REPLIES 5
Steven E. Protter
Exalted Contributor

Re: System pings an IP address but won't ping a host name

Shalom,

Check how hostname resolution is done in /etc/nsswitch.conf

Normally its a good idea to do files first and to make that ping work you need an entry in /etc/hosts

ip_address hostname

Then ping hostname will work.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Asif Sharif
Honored Contributor

Re: System pings an IP address but won't ping a host name

Salam Hassan,

check your /etc/hosts file.

Regards,
Asif Sharif
Regards,
Asif Sharif
Jim Keeble
Trusted Contributor

Re: System pings an IP address but won't ping a host name

Try "nsquery hosts " . It will show you how nsswitch.conf is interpreted:

$ nsquery hosts hpprsc2s

Using "dns [NOTFOUND=continue TRYAGAIN=continue] files" for the hosts policy.

Searching dns for hpprsc2s
hpprsc2s was NOTFOUND

Switch configuration: Allows fallback

Searching /etc/hosts for hpprsc2s
Hostname: hpprsc2s
Aliases:
Address: 15.97.1.66
Switch configuration: Terminates Search
Bill Hassell
Honored Contributor

Re: System pings an IP address but won't ping a host name

Hostnames are meaningless to networking. They are only an alias for humans because numbers are hard to remember. Basic network setup will use the entries in /etc/hosts. If the name is not in /etc/hosts then ping doesn't know what to do. However, if you have setup DNS (by editing /etc/resolv.conf) then hostnames are kept on another server which may or may not be correct. Talk to your DNS administrator if the hostname doesn't match the real IP address. To check, use nslookup or nsquery.


Bill Hassell, sysadmin
Jeeshan
Honored Contributor

Re: System pings an IP address but won't ping a host name

if you want to ping any machine by hostname, you must have an entry in /etc/hosts file.

check that file for syntax.
a warrior never quits