/etc/hosts file not being used before DNS server query
12,481
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!
Related videos on Youtube
Author by
jwbensley
Updated on September 18, 2022Comments
-
jwbensley over 1 year
I have upgraded to Ubuntu 12.10 and I have made entries in
/etc/hosts
, but instead of looking into thehosts
file, queries to my configured DNS server are being made first.How can I make Ubuntu query the
/etc/hosts
file first?Thanks.
-
NickTux over 11 yearsIs this helps ?
-
jwbensley over 11 yearsThanks 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. -
Reza Zamani over 11 yearsDid you check if
files
is listed BEFOREdns
underhosts
in/etc/nsswitch.conf
? This is the definition of the order in which they will be queried. -
jwbensley over 11 yearsGood suggestion;
cat nsswitch.conf | grep hosts
hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4
-