Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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 upgraded to Ubuntu 12.10 and I have made entries in /etc/hosts, but instead of looking into the hosts file, queries to my configured DNS server are being made first.

How can I make Ubuntu query the /etc/hosts file first?


share|improve this question
Is this helps ? – NikTh Oct 21 '12 at 12:04
Thanks for the suggestion NikTh but that's not my problem. My entires aren't being removed, they are always there, they just aren't being used. If I execute host where "" is an entry in my hosts file, I seem to always get the IP given out by my DNS server which is different to that in my hosts file. Sometimes it works, mostly it doesn't though. – jwbensley Oct 21 '12 at 12:07
Did you check if files is listed BEFORE dns under hosts in /etc/nsswitch.conf? This is the definition of the order in which they will be queried. – Celada Oct 21 '12 at 14:42
Good suggestion; cat nsswitch.conf | grep hosts hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4 – jwbensley Oct 21 '12 at 14:53
up vote 7 down vote accepted

Turns out I am a massive buffoon;

The host command just seems to ignore the /etc/hosts file and perform queries against your configured DNS servers directly. If I ping I am using my /etc/hosts file entry, and after installing wireshark I can see that chrome is too.

Hope that helps someone!

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.