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

command linedns

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)?

Best Answer

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.