Disable DNS Cache on macOS

Hi! I am looking for a way to permanently disable DNS Cache on macOS. This is well documented and easily done on Windows or Linux operating systems but somehow the internet is silent on how to get this implemented on Mac.

Any help is greatly appreciated! Thanks, Alik

Not sure if you can disable the DNS cache without disabling DNS completely.

To stop and continue queries try sudo killall -STOP mDNSResponder and sudo killall -CONT mDNSResponder. Also not sure what layers this affects and what they might cache.

You can still flush the DNS cache easily using sudo killall -HUP mDNSResponder so repeated calls might appear like a disabled cache. https://support.apple.com/en-us/HT202516

Use dns-sd -q apple.com  to verify this:  

dns-sd -Q apple.com
DATE: ---Tue 19 Jul 2022---
15:20:11.663  ...STARTING...
Timestamp     A/R    Flags if Name                          Type  Class   Rdata
15:20:11.664  Add 40000002  0 apple.com.                    Addr   IN     17.253.144.10
15:20:14.156  Rmv        0  0 apple.com.                    Addr   IN     17.253.144.10
15:20:14.166  Add        2  0 apple.com.                    Addr   IN     17.253.144.10

Some historical commands are now deprecated with SIP and for security.

sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist
/System/Library/LaunchDaemons/com.apple.mDNSResponder.plist: Operation not permitted while System Integrity Protection is engaged
man mDNSResponder
sudo killall -INFO mDNSResponder  
Sending SIGINFO to mDNSResponder daemon is deprecated. To trigger state dump, please use 'dns-sd -O', enter 'dns-sd -h' for more information
sudo dns-sd -O
XPC service returns error, description: State dump is only enabled in internal builds

Thank you for your help! Is there a config file for mDNSResponder? I wonder if there could be a way to configure DNS Cache through that

What was the context / reason for disabling the DNS cache?

Disable DNS Cache on macOS
 
 
Q