Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

Thanks.

share|improve this question
1  
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 www.somesite.com where "www.somesite.com" 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
2  
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
add comment

1 Answer

up vote 4 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 www.somesite.com 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
add comment

Your Answer

 
discard

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.