4

The man files for dig, delv and host all contain: "macOS Notice The [dig | delv | host] command does not use the host name and address resolution or the DNS query routing mechanisms used by other processes running on macOS."

I've only found this, apparently, non-authoritative mechanism answer: https://apple.stackexchange.com/a/70583/246634

The dscacheutil man page does not document that one can make an authoritative DNS query using dscacheutil.

How does one make a command line authoritative DNS query using macOS Mojave native host name and address resolution mechanism(s)?

1 Answer 1

6

The way to do a command line DNS query using macOS Mojave's native host name and address resolution mechanism is through dscacheutil like this:

dscacheutil -q host -a name www.google.com

This will use the native mechanism so that the response will come from cache, if it is cached, and if not it will be looked up through standard address resolution (i.e. typically from a recursive DNS server) and the answer will be placed in cache.

I suspect that you already know of this method, and thus have added the word "authoritative" to the title of your question to specify that you want to lookup the address directly from the authoritative DNS server instead of through a recursive DNS server for example.

Unfortunately this makes the question a kind of oxymoron - i.e. it doesn't really make sense. Because if you're using the native address resolution mechanism like most normal macOS programs, you're not just making a query to an authoritative DNS server - you're interacting with a cache and its address resolution policy.

If you want to make an authoritative query from the command line on macOS Mojave, you can do that by the following command for example:

dig @a.r06.twtrdns.net www.twitter.com

This means that the query goes directly to the authoritative DNS server. Ofcourse this bypasses the standard way of resolving names, so this doesn't interact with macOS Mojave's native address resolution mechanism.

I hope this answer your question even though it doesn't try to answer the impossible "both at the same time". But perhaps you meant something else, which wasn't clear in your question. Perhaps you're looking to query the cache and recursive servers through the native address resolution mechanism, but only to get at the authoritative section of the DNS reply (if any DNS reply is involved at all ofcourse) - or something like that.

3
  • NTA, but +1 because I had no idea dscacheutil could be used this way!
    – Nic
    Commented Mar 18, 2020 at 0:32
  • Could you add some information about how one finds out the actual DNS server used by dscacheutil if it does not have the entry in the cache?
    – jstarek
    Commented Mar 22, 2021 at 17:57
  • @jstarek That's now really what this question was about. What about opening a new question for that? - Then I'll reply with how to do that seperately. You can do that both by looking in System Preferences > Network - and from the command line.
    – jksoegaard
    Commented Mar 23, 2021 at 11:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .