Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have almost fresh Ubuntu desktop box. OS was installed two weeks ago and updated from karmic repositories. Last week I had no problems with DNS. But this week something had changed. I'm not sure what and when, and not sure whether I changed any configs.

So now I have some really weird situation. According to logs name resolving should work normally.

/etc/hosts   localhost test   desktop


order hosts,bind
multi on


# Generated by NetworkManager
search search servers obtained via DHCP


passwd:         compat
group:          compat
shadow:         compat

hosts:          files mdns4_minimal [NOTFOUND=return] dns mdns4
networks:       files

protocols:      db files
services:       db files
ethers:         db files
rpc:            db files

netgroup:       nis

But if fact it is not.

user@test ~>ping test

PING localhost ( 56(84) bytes of data.

Pinging is ok.

user@test ~>host test has address

I suspect that NetworkManager might cause this misbehavior, but don't know where to start to check it. Any thoughts, suggestions?

share|improve this question
up vote 14 down vote accepted

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.

The same is also true for dig and nslookup - they're DNS specific too.

share|improve this answer
So, you're saying, host utility doesn't use /etc/hosts? And there's nothing to fix in my case? – z4y4ts Mar 12 '10 at 15:20
yup, pretty much - nothing to see here :) – Alnitak Mar 12 '10 at 15:34
What I don't get is that host >used to< be the "regular" name-querying command, obeying /etc/nsswitch.conf – mveroone Dec 21 '15 at 10:45
@Kwaio I can find no evidence in the ISC sources that host ever did – Alnitak Dec 21 '15 at 15:11
Well I might have used unsual distribution implementations, then, my bad. – mveroone Jan 7 at 8:31

The host command (along with dig and nslookup) is part of the bind DNS utilities. As a DNS resolver utility, it does DNS resolution alone.

If you're interested in fetching an entry from any libnss-driven data store, you can use the getent program. To get a hosts entry, for example, use it like this:

getent hosts

This follows follows the resolution order set out under hosts: in /etc/nsswitch.conf in order, which includes /etc/hosts if "files" is lised as one of the options.

share|improve this answer

For me this issue occurred due to incorrect file permissions. Only root could read /etc/hosts. The file should be world-readable.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.