High Sierra DNS fails intermittently for LAN-local hosts

dns

I have a local domain for my home network, which uses .loc as a TLD (not .local). Name resolution for hosts on that network always works using dig or nslookup from a terminal, but intermittently fails everywhere else. One day it will work fine and I'll start regrowing my hair, and the next I'm unable to ssh to another machine to save my life.

Is this an mDNSResponder/Bonjour issue? I have tried simply disabling mDNSResponder, but SIP disallows it (and IT is unlikely to go along with disabling SIP). Flushing DNS doesn't help. What else can I try?

mac:~ user$ sudo killall -HUP mDNSResponder
mac:~ user$ scp ~/.ssh/id_rsa.pub user@kube1.domain.loc:/id_rsa.pub
ssh: Could not resolve hostname kube1.domain.loc: nodename nor servname provided, or not known
lost connection
mac:~ user$ dig kube1.domain.loc

; <<>> DiG 9.8.3-P1 <<>> kube1.domain.loc
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 59092
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;kube1.domain.loc.          IN  A

;; ANSWER SECTION:
kube1.domain.loc.       900 IN  A   10.0.0.130

;; Query time: 4 msec
;; SERVER: 10.0.0.10#53(10.0.0.10)
;; WHEN: Thu Feb  1 18:59:51 2018
;; MSG SIZE  rcvd: 48

mac:~ user$ 

Best Answer

macOS doesn't treat its DNS server list as having any sort of priority at all, it just scatters queries across all of them in a semirandom fashion. Set it to only use the internal DNS server, and you should get much more reliable lookups.