nv-l

Re: [nv-l] Re: Help with name resolution on Linux

2004-12-22 21:05:30
Subject: Re: [nv-l] Re: Help with name resolution on Linux
From: Joe Fernandez <jfernand AT kardinia DOT com>
To: nv-l AT lists.us.ibm DOT com
Date: Thu, 23 Dec 2004 12:56:56 +1100
At 01:19 PM 21-12-04 -0500, you wrote:
Has anyone encountered this? I'm trying to override DNS with /etc/hosts. It appears that you do this in /etc/nsswitch.conf and /etc/host.conf on Linux, similar to Solaris. And the host command behaves differently than it does on AIX - it always checks only dns, like nslookup. The same with the 'dig' command. So it is tricky to verify just what is going on. It appears to me that it works for forward resolution, but not for backward resolution.

That is,  gethostbyname  respects the order that you set in nsswitch.conf
     hosts:  files dns
and in /etc/host.conf
     order hosts, bind
     multi on
but gethostbyaddr does not.

Suggestions welcome.
Cordially,
Leslie A. Clark
IBM Global Services - Systems Mgmt & Networking
(248) 552-4968 Voicemail, Fax, Pager

Leslie,

I believe "dig" is meant to only look up the DNS.

On the other hand, both gethostbyname and gethostbyaddr will do a search in the order you specify in the nsswitch.conf and host.conf files as you  list above.

I ran a check on one of our Red Hat systems.

1. The default settings of the conf files were as you have them above, without the "multi on"
2. I executed a gethostbyname on www.ibm.com, got a list of IP addresses, picked one and issued a gethostbyaddr and got back www.ibm.com
3. I made an entry in the hosts file defining www.ibm.com as 10.1.1.1
4.  I executed a gethostbyname on www.ibm.com, got 10.1.1.1, executed a gethostbyaddr on 10.1.1.1 and got back www.ibm.com
5. I reversed the order in the conf files, repeated the previous step and got the results of step 2 rather than step 4.

This suggests to me that both gethostbyname and gethostbyaddr  take their order from the conf files....at least on this system.

I can send you the command line program I used to test it, if it is of use to you.


Joe Fernandez
Kardinia Software
jfernand AT kardinia DOT com
<Prev in Thread] Current Thread [Next in Thread>