Hi,

We have a strange problem that I never experienced before and cannot explain, but doesn't seem to be the right behavior nevertheless.

When you resolve a hostname on RHEL5 (RHEL4 is affected too) that is in /etc/hosts, libresolv performs a DNS lookup. If your DNS is unavailable for whatever reason, it takes a long timeout for DNS before it returns the answer from /etc/hosts...

This is easy to verify:

 - Add a fake name to /etc/hosts

        1.2.3.4         testsys

 - Make sure /etc/nsswitch.conf has

        hosts:  files dns

 - Add a non-working DNS server at the top of /etc/resolv.conf

        nameserver 4.3.2.1

 - Perform a namelookup and see that it times out

        getent hosts testsys
        getent hosts 1.2.3.4

 - Verify that a namelookup is not performed when doing

        getent hosts

Even when you configure /etc/nsswitch to do:

        hosts:  files [SUCCESS=return] dns

it fails to work as we would expect. What am I not understanding ?

From stracing the getent lookups it is clear it opens /etc/hosts first
then does a DNS lookup and then opens /etc/hosts again before printing the answer.

Does anyone know what is going on ?

Thanks in advance,
--
--   dag wieers,  [email protected],  http://dag.wieers.com/   --
[Any errors in spelling, tact or fact are transmission errors]

_______________________________________________
rhelv5-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/rhelv5-list

Reply via email to