MacOS – Lion resolving DNS names when querying server directly, but not when used in a command or app

dnsmacosNetwork

I've recently (as in minutes ago) added a hostname and reverse (A and PTR) records for a hostname on my internal network, using a Bind DNS server. For some reason, i can both dig and nslookup this new name successfully, but ping and my GUI applications can not resolve the name.

I have attempted flushing the DNS cache on my local machine with dscacheutil -flushcache to no effect.

Here's an example of my session (names, IPs changed for security):

$ nslookup newbox.internal
server     10.0.0.2
address    10.0.0.2#53

Name:    newbox.internal
Address: 10.1.1.1

$ ping newbox.internal
ping: cannot resolve newbox.internal: Unknown host

WTF? Okay, I'm sure my DNS is set up correctly though:

$ dig newbox.internal

; <<>> DiG 9.8.3-P1 <<>> newbox.internal
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 33812
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 4, ADDITIONAL: 4

;; QUESTION SECTION:
;newbox.internal.   IN  A

;; ANSWER SECTION:
newbox.internal. 21600 IN   A   10.1.1.1

;; AUTHORITY SECTION:
internal.       10800   IN  NS  dns001.internal.
internal.       10800   IN  NS  dss001.internal.
internal.       10800   IN  NS  dhdns001.internal.
internal.       10800   IN  NS  dhdns002.internal.

;; ADDITIONAL SECTION:
dns001.internal. 10800 IN   A   10.0.0.2
dns002.internal. 10800 IN   A   10.0.0.3
dhdns001.internal. 10800 IN A   10.0.0.20
dhdns002.internal. 10800 IN A   10.0.0.21

;; Query time: 1 msec
;; SERVER: 10.0.0.2#53(10.0.0.2)
;; WHEN: Mon Jul  1 14:43:35 2013
;; MSG SIZE  rcvd: 245

Why does my system demonstrate this odd DNS resolver behavior?

As a side note, DNS works fine otherwise on my system. At this moment, this new hostname is the only one I'm having trouble resolving. My system is configured to use the 10.0.0.2 DNS server as it's primary.

EDIT

Killing mDNSResponder fixed this issue.. but why?

Best Answer

Killing mDNSResponder fixed this issue.. but why?

Because you flushed the local DNS cache!

http://support.apple.com/kb/ht5343

A direct lookup command will query the DNS server directly, however the resolution mechanism for just about anything else is that mDNSResponder process you killed.

dscacheutil -flushcache is deprecated as per the KB.