nsswitch.conf seems to be ignored

I have the standard
Code:
hosts: files dns
in /etc/nsswitch.conf, but it seems to be ignored.
/etc/hosts contains a line
Code:
192.168.n.n xxxx.yyyy xxxx
but host xxxx produces:
Code:
 host xxxx
xxxx has address 192.168.n.n
Host xxxx not found: 3(NXDOMAIN)

If I delete the "dns" option from /etc/nsswitch.conf and even reboot, it makes no difference. What do I have to do to enable the host command to accept the result from /etc/hosts and not query DNS?
 
What do I have to do to enable the host command to accept the result from /etc/hosts and not query DNS?
Some utilities choose the resolvers by direction (i.e. consult /etc/nsswitch.conf).

Others do what their designers intended, and go straight to the DNS.

The host command was written by the Internet Systems Consortium to be used with the DNS, and the manual page for the host(1) command says "host is a simple utility for performing DNS lookups". So it uses the DNS... Sometimes you really do want this, however it's an exception -- most utililities using the standard resolvers will work as you expect.

If you want the DNS resolvers to always resolve from a hosts file before consulting any upstream DNS servers, installing the dns/dnsmasq port for your primary name server will enable this. But, in that case, you would want to be maintaining just one hosts file for your site, so you would install dns/dnsmasq on your firewall (or, at least, your primary internal name server) and point all your internal DNS clients at it.
 
Back
Top