Like the title says, running os x 10.10.1. if i have an entry in my hosts file and do a dig
or nslookup
it still shows a different IP than what is in my hosts file even after trying to flush various caches.
I have tried the following..
- flush mdns and udns caches by running:
sudo discoveryutil mdnsflushcache;
sudo discoveryutil udnsflushcaches;
- flush cache using
dscacheutil -flushcache
- reload the
discoveryd.plist
filesudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.discoveryd.plist
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.discoveryd.plist
my hosts file looks like this..
% cat /private/etc/hosts
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
166.78.60.102 admin.devsite1.com
Best Answer
/private/etc/hosts seems to be working normally for me in Yosemite (version 10.10.1). It's not necessary to flush the cache or reset
discoveryd
(the DNS resolver in Yosemite);sudo fs_usage | grep private/etc/hosts
showsdiscoveryd
reading the file immediately after I save changes to it.[Update:
discoveryd
was only used in OS X versions 10.10.0 - 10.10.3. In both earlier and later versions,mDNSResponder
provides the same function... and also immediately notices changes in /etc/hosts.]However,
dig
,nslookup
, andhost
will not see entries in it because they bypass the system's resolver and do raw DNS lookups. They've always done this, so this is not new in Yosemite. The "official" way to do a lookup through the system resolver in OS X is to usedscacheutil
:...but since that's painfully verbose, I tend to just use
ping
instead (and then look at the first line, where it lists what IP it's pinging). Starting in 10.9, you can also use Network Utility's Lookup tab (before that it useddig
, and therefore bypassed the system lookup policy).BTW, please pay no attention to the macrumors thread that Tetsujin linked; it's full of people who don't quite know what they're doing and are misunderstanding the results of their own mistakes.