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

Tring to ping a hostname fails: #ping: unknown host xxxxxx

SOLVED
Go to solution
JD White
Advisor

Tring to ping a hostname fails: #ping: unknown host xxxxxx

As root I can ping other servers on my network if I use their IP address but ping fails if I ping using their hostname. 

 

I have he same issue with all host names but will only use one as as example to try and keep it simple to follow.

 

# /usr/sbin/ping servername
/usr/sbin/ping: unknown host servername

 

I'm open to any ideas! 

Thanks in Advance

 

JD

 

Reference Material  Below ##################################################

 

Software:      HP-UX [SERVERNAME] B.11.31 U ia64 2856419228 unlimited-user license

 

# ll /usr/sbin/ping

-r-sr-xr-x   1 root       bin          78432 Feb 15  2007 /usr/sbin/ping

 

# ll /etc/nsswitch.conf
-r--r--r--   1 bin        bin            508 Aug  9 09:27 /etc/nsswitch.conf
 

# cat /etc/nsswitch.conf
passwd:       files
group:        files
hosts:        files [NOTFOUND=CONTINUE] dns
ipnodes:      files
networks:     files
protocols:    files
rpc:          files
publickey:    files
netgroup:     files
automount:    files
aliases:      files
services:     files

# cat /etc/resolv.conf

domain SERVERNAME.DOMAIN.NAME 
nameserver XXX.XXX.XXX.XXX
nameserver YYY.YYY.YYY.YYY
nameserver ZZZ.ZZZ.ZZZ.ZZZ

 

# ll /etc/hosts
-rw-r--r--   1 root       sys           6474 Aug  9 07:45 /etc/hosts

# grep csohpb /etc/hosts
xxx.xxx.xxx.xxx  SERVERNAME.DOMAIN.NAME. SERVERNAME servername

# ping xxx.xxx.xxx.xxx            (Works)
PING xxx.xxx.xxx.xxx: 64 byte packets
64 bytes from xxx.xxx.xxx.xxx: icmp_seq=0. time=0. ms
64 bytes from xxx.xxx.xxx.xxx: icmp_seq=1. time=0. ms

# nslookup servername    (Works)
Using /etc/hosts on:  servername
looking up FILES  
Name:    servername.domain.name.
Address:  xxx.xxx.xxx.xxx
Aliases:  SERVERNAME,servername

# /usr/contrib/bin/nsquery hosts servername   (Works)

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

Searching /etc/hosts for servername
Hostname: SERVERNAME.DOMAIN.NAME
Aliases: . SERVERNAME servername
Address: xxx.xxx.xxx.xxx:
Switch configuration: Terminates Search

 

12 REPLIES
donna hofmeister
Trusted Contributor

Re: Tring to ping a hostname fails: #ping: unknown host xxxxxx

de-obsfucating your examples would be helpful...as 'servername' is being used for all server names and we (at least me anyhow) can't tell what's what///

 

if you do:

# nsquery hosts otherserver "files dns"

# nsquery hosts otherserver "dns files"

what is the result?

JD White
Advisor

Re: Tring to ping a hostname fails: #ping: unknown host xxxxxx

# /usr/contrib/bin/nsquery hosts SERVERNAME "files dns"

Using "files dns" for the hosts policy.

Searching /etc/hosts for SERVERNAME
Hostname: SERVERNAME.XXXXX.ARMY.MIL
Aliases: SERVERNAME
Address: XXX.138.24.162
Switch configuration: Terminates Search

 

# /usr/contrib/bin/nsquery hosts SERVERNAME "dns files

Using "dns files" for the hosts policy.

Searching dns for SERVERNAME
SERVERNAME was NOTFOUND

Switch configuration: Allows fallback

Searching /etc/hosts for SERVERNAME
Hostname: SERVERNAME.XXXX.ARMY.MIL
Aliases: ASERVERNAME
Address: XXX.138.24.162
Switch configuration: Terminates Search

donna hofmeister
Trusted Contributor

Re: Tring to ping a hostname fails: #ping: unknown host xxxxxx

and you're doubly triple sure your entry for this server is correct in /etc/hosts?  there's not a 2nd line with the same IP address or servername?

 

If you take the line out and put it back in (and actually type it, not copy-n-paste) does that help?

 

afaik, /etc/hosts is NOT case-sensitive.  Can you try simplyfying your /etc/hosts line to:

xx.xx.xx.xx       server.domain.com server

 

does that help?

 

what if you modify your nsswitch line to:

hosts: files     [NOTFOUND=continue UNAVAIL=continue TRYAGAIN=continue] dns

 

does anything change?

JD White
Advisor

Re: Tring to ping a hostname fails: #ping: unknown host xxxxxx

1.  Verified only one entry.  ping fails on any of the 100 + entries in /etc/host file I try.

 

2.  I tried the changes to /etc/nsswitch.conf and I get the same results.  There is no pause between the time you press enter and it fails so I don't think we are getting to the point where it trys to use the DNS. 

 

ping: unknown host SERVERNAME
# echo $?
1

I have tried on 3 of my servers and they all do the same thing.

donna hofmeister
Trusted Contributor
Solution

Re: Tring to ping a hostname fails: #ping: unknown host xxxxxx

can you check to see if 'domain' is commented out or not in /etc/services?  (port 53)

JD White
Advisor

Re: Trying to ping a hostname fails: #ping: unknown host xxxxxx

Donna you win the kewpie doll!   

 

Thanks it's working now.  We've had "domain" commented out for a long time and it was working.  Guess we were lucky or one of the new patches fixed something we didn't know was broken.    Would love to give you a Kudeo but  haven't figured that part out yet!  :-(  If you can point me in the correct direction I'll be happy to give you one!

 

Thanks for your help Donna and everyone else also.

 

 

Kris_Knigga
Trusted Contributor

Re: Trying to ping a hostname fails: #ping: unknown host xxxxxx

Just click the "Kudos!" button.

Kris Knigga
donna hofmeister
Trusted Contributor

Re: Trying to ping a hostname fails: #ping: unknown host xxxxxx

cool :-)  you're welcome :-)

 

fwiw, this is a change in behavior beginning with 11.31:

 

Starting at 11.31 ping uses the newer getaddrinfo() and getnameinfo() hostname resolution calls which are part of the POSIX standard API for both IPv4 and IPv6 hostname resolution. In the case of the ping program the following is a example of a similar getaddrinfo() call:

getaddrinfo(hostname, "domain", NULL, &result))

In this case "domain" is a service as defined in /etc/services , or NIS or ldap depending on how your /etc/nsswitch files is configured to provide services information. The /etc/services is used to map a name to a port number (or service) and in the case of the system experiencing the ping problem the following was commented out of /etc/services :


# domain        53/tcp  nameserver     # Domain Name Service
# domain        53/udp  nameserver     #

The default /etc/services as shipped with the system has the following entry for domain:


# grep domain /usr/newconfig/etc/services
domain        53/tcp  nameserver     # Domain Name Service
domain        53/udp  nameserver     #

Note that these 2 entries are not commented out.

i've seen many cases where boxB is replacing boxA.  boxB is going to replace boxA.  boxB is newer than boxA.  To make boxB look and smell as much as possible as boxA lots of /etc files get copied from A --> B and then we all go running about with our hands in the air going "it doesn't work!"

 

those files in 'newconfig' are your friends :-)

JD White
Advisor

Re: Trying to ping a hostname fails: #ping: unknown host xxxxxx

Kris,

 

Funny thing is when I'm not logged in I can see the Kudo Button.  However, once I login it disappears which is why I could figure it out before.  :-|

 

See Attachment

JD White
Advisor

Re: Trying to ping a hostname fails: #ping: unknown host xxxxxx

Well you got me on that one plus we get scanned so oftern here we have to keep all but a 5 ports turnned off.  Now I know the trick I'll turn domain on when I need to ping by hostname off when I finish.  Thanks again for your help!

Steven Schweda
Honored Contributor

Re: Trying to ping a hostname fails: #ping: unknown host xxxxxx

 
Stephan.
Honored Contributor

Re: Trying to ping a hostname fails: #ping: unknown host xxxxxx

Make sure that "Hide Kudos buttons and counts" is not active in your profile.

 

http://h30499.www3.hp.com/t5/user/myprofilepage/tab/user-preferences%3Akudos

 

hth,

Stephan


JD White wrote:

Kris,

 

Funny thing is when I'm not logged in I can see the Kudo Button.  However, once I login it disappears which is why I could figure it out before.  :-|

 

See Attachment