Apple - DNS not resolving on Mac OS X
It turns out the solution was to bounce mDNSResponder:
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist
This was obtained by a different coworker from this Server Fault question.
OS X 10.10.0 – 10.10.3, Yosemite
Apparently, mDNSResponder doesn't exist in Yosemite (OS X 10.10). You can restart descoveryd instead to fix these issues.
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.discoveryd.plist
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.discoveryd.plist
OS X 10.10.4+, Yosemite
In OSX 10.10.4 the mDNSResponder has been reintroduced. So use the first one will work again.
Actually, I think you might want to use
scutil --dns
scutil -r hostname
These commands use the dynamic store in configd, as opposed to the flatfiles in /etc, which often are only read in single user mode and for non networked systems.
man scutil # or
scutil --help
I've experienced the same problem… And while restarting mDNSResponder does seem to "work", restarting it a couple of times every hour sort of sucks.
So, for now, I've "solved" the problem by running dnsmasq locally. To do that:
- Build dnsmasq (download the tgz and
make
orbrew install dnsmasq
) Put this in a
dnsmasq.conf
file:resolv-file=resolv.conf user=nobody group=nobody interface=lo0 cache-size=1024
Put this in a
resolv.conf
file that is in the same directory as thednsmasq.conf
file (nb: not/etc/resolv.conf
):nameserver 8.8.8.8 nameserver 4.2.2.1 nameserver 4.2.2.2
Run
dnsmasq
withsudo dnsmasq --no-daemon --log-queries -C dnsmasq.conf
. The output should look something like:... dnsmasq: reading resolv.conf dnsmasq: using nameserver 4.2.2.1#53 dnsmasq: using nameserver 4.2.2.2#53 dnsmasq: using nameserver 8.8.8.8#53 dnsmasq: read /etc/hosts - 6 addresses
Open Network Preferences and make sure that
127.0.0.1
is the only DNS server (network preferences -> advanced -> DNS -> add 127.0.0.1)
Things should begin to work nicely again.
Once things are working, you can run dnsmasq
without the --no-daemon
and --log-queries
options, so it will start in the background and you don't need to keep a Terminal window open.