Do entries in local 'hosts' files override both forward and reverse name lookups?

Posted by Murali Suriar on Server Fault See other posts from Server Fault or by Murali Suriar
Published on 2009-07-20T11:07:07Z Indexed on 2012/09/18 15:41 UTC
Read the original article Hit count: 349

Filed under:
|
|

If I have the following entries in a hosts file:

192.168.100.1    bugs
192.168.100.2    daffy.example.com
192.168.100.3    elmer.example.com.

Will IP->name resolution attempts by local utilies (I assume using 'gethostbyaddr' or the Windows equivalent) honour these entries? Is this behaviour configurable? How does it vary between operating systems? Does it matter whether the 'hosts' file entries are fully qualified or not?

EDIT: In response to Russell, my test Linux system is running RHEL 4. My /etc/nsswitch.conf contains the following 'hosts' line:

hosts:      files dns nis

If I ping any of my hosts by name (e.g. bugs, daffy), the forward resolution works correctly. If I traceroute any of them by IP address, the reverse lookup functions as expected. However, if I ping them by IP, ping doesn't appear to resolve their host names. My understanding was that Linux ping would always attempt to resolve IPs to names unless instructed otherwise. Why would traceroute be able to handle reverse lookups in hosts files, but ping not?

© Server Fault or respective owner

Related posts about dns

Related posts about hosts