2

I was struggling trying to find out the reason why the linux host utility was ignoring my /etc/hosts file until I find the answer to my question here: hosts file seems to be ignored:

With this configuration, most applications will happily work with your entry from /etc/hosts. However host doesn't look at /etc/nsswitch.conf. That is by design, not by accident, since host is specifically a DNS lookup program. /etc/hosts is not DNS, it's (mostly) what we used before we had DNS.

However, as far as I'm concerned, the utility didn't use to behave like this back in the not-so-old days.

I'm pretty sure host DID check the /etc/hosts file...

Am I just going crazy after a very tough day or am I correct?

If I'm correct, does anyone know why and when they changed it?

I noticed it on CentOS 5.6 and 6.0 servers.

1 Answers1

5

This sounds like a complaint, not a question.

host does a DNS lookup and is distributed as part of the bind DNS system. It doesn't resolve a name, which could involve not only /etc/hosts and DNS, but could also involve YP, LDAP, NMB (samba), and any other nss plugin.

If you're interested in a "normal" host resolution, you can use the getent utility (which you won't be surprised to learn is part of coreutils, along with libnss).

getent hosts google.com
tylerl
  • 15,245