Operating System - HP-UX
1819684 Members
3499 Online
109605 Solutions
New Discussion юеВ

gethostbyname not working, nslookup on same host work fine

 
SOLVED
Go to solution
Uffe Gavnholt_1
Honored Contributor

gethostbyname not working, nslookup on same host work fine

Hi All,


I'm having a strange problem on my hpux 11i system.

My dns is configured to start looking in the host file, if unsuccessfull the dns is queried.

The problem is with some hosts, when I try to resolve them by their name, gethostbyname fails, but nslookup doesn't for the same node.

If I manually add the node to the /etc/hosts file, both work.

Anyone heard of this?

Thank you

Uffe
8 REPLIES 8
Ashwani Kashyap
Honored Contributor

Re: gethostbyname not working, nslookup on same host work fine

what does your nsswitch.conf file look like .

after the host entry do you have NOTFOUND=continue and UNAVAIL=continue r do you have return instead of continue .
Sanjay_6
Honored Contributor

Re: gethostbyname not working, nslookup on same host work fine

Hi,

Look at the resolv.conf file on your system and see if the domain name or the search order is defined correctly. If that is okay then look at the configuration file on your dns.

Hope this helps.

Regds
Uffe Gavnholt_1
Honored Contributor

Re: gethostbyname not working, nslookup on same host work fine

Here is the nsswitch.conf

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

My search domains should be ok
Mel Burslan
Honored Contributor

Re: gethostbyname not working, nslookup on same host work fine

just curious, is this happening to this system only or do you have other systems experiencing the same problem ? Lookslike your address resolution is working but communication with the dns server (or lack thereof) is the problem and I am wondering if your dns server is having issues.

Just an idea
________________________________
UNIX because I majored in cryptology...
Mark Grant
Honored Contributor

Re: gethostbyname not working, nslookup on same host work fine

You need to check h_errno to see if there is an error from gethostbyname(). Some errors are tempory and a retry will do the trick.
Never preceed any demonstration with anything more predictive than "watch this"
harry d brown jr
Honored Contributor
Solution

Re: gethostbyname not working, nslookup on same host work fine

Uffe,

change your "hosts" line in nsswitch.conf to look like this:

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


live free or die
harry
Live Free or Die
Uffe Gavnholt_1
Honored Contributor

Re: gethostbyname not working, nslookup on same host work fine

Hi Harry,


I don't quite understand why, but it did the trick


Thank you, you'll be in my prayer tonight ;o)

Uffe
Brian Hackley
Honored Contributor

Re: gethostbyname not working, nslookup on same host work fine

Uffe, ITRC gurus,

A trick to use for debugging this kind of problem is "nsquery hosts" followed by the hostname you are looking for.

Example,
jbox# nsquery hosts www.atl.hp.com

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

Searching /etc/hosts for www.atl.hp.com
www.atl.hp.com was NOTFOUND

Switch configuration: Allows fallback

Searching dns for www.atl.hp.com
Hostname: www.atl.hp.com
Aliases:
Address: 15.51.240.8
Switch configuration: Terminates Search
jbox#

Best regards, Brian Hackley
Ask me about telecommuting!