[TriLUG] Reverse Lookup Using /etc/hosts

Kevin Otte nivex at nivex.net
Wed Apr 25 16:59:03 EDT 2007


On Wed, Apr 25, 2007 at 04:23:45PM -0400, Tarus Balog wrote:
> Gang:
> 
> I am at a site where a bunch of devices don't reverse resolve via  
> DNS. I have a spreadsheet with the IPs and the hostnames so I've  
> created an /etc/hosts file in the proper format with that  
> information, and in nsswitch.conf I've set hosts to files then dns.
> 
> However, host/nslookup will not resolve the IP to a name.

That's because host/nslookup are strictly for checking DNS.  Most system
calls (like getHostByName) will follow the order in nsswitch, which usually
files then DNS.

You can see if it's resolving through NSS with the 'getent' command:

[kjotte at aaladm104 ~]$ getent hosts 127.0.0.1
127.0.0.1       localhost.localdomain localhost
[kjotte at aaladm104 ~]$ getent hosts 4.2.2.2
4.2.2.2         vnsc-bak.sys.gtei.net
[kjotte at aaladm104 ~]$ getent hosts www.nivex.net
64.246.96.38    www.nivex.net

-- 
Kevin Otte, N8VNR
nivex at nivex.net
http://www.nivex.net/

-=-

"Those who cannot remember the past are condemned to repeat it." 
-- George Santayana

"It seems no one reads Santayana anymore."
-- Cdr. Susan Ivanova, Babylon 5




More information about the TriLUG mailing list