macOS

Disable Multicast Advertisement (Bonjour)

Bonjour is Apple’s implementation of Multicast DNS.

Despite the fact that mDNS has been around since 2000 many people don't even use it. Unfortunetly you can’t just disable the mDNSResponder LaunchDaemon or the DNS will be broken.

Instead, to disable Bonjour altogether (which breaks DNS) we need add the -NoMulticastAdvertisements option into the ProgramArguments array of the com.apple.mDNSResponder.plist file.

Disable

It is important to disable the service BEFORE changing anything in the service plist file, otherwise it's socket might get buggy and you won't be able to restart the service.

To unload (disable) the service issue a:

sudo launchctl unload /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist

Now that the service is off insert the "NoMulticastAdvertisements" into the configuration file:

sudo defaults write /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist ProgramArguments -array-add "-NoMulticastAdvertisements"

Now reload the service, this time it will load without Bonjour advertisement:

sudo launchctl load /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist

(re)Enable / Undo

To undo this (enable DNS Multicasting), first unload the mDNSResponder service:

sudo launchctl unload /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist

Then reconfigure the daemon without the "-NoMulticastAdvertisements" flag by reseting the array to it's default values:

sudo defaults write /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist ProgramArguments -array "/usr/sbin/mDNSResponder" "-launchd"

Now reload mDNSResponder service:

sudo launchctl load /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist

Fixing Problems

If you mess with the daemon while is still loaded there is a chance the socket for it will be unusable and stuck. If you are trying to reload the daemon and it won't reload, check the logs in the Console.app. For example:

12/27/16 4:05:28.768 PM com.apple.xpc.launchd[1]: (com.apple.mDNSResponder.reloaded[1428]) Service could not initialize: 15G17023: xpcproxy + 12684 [1462][04735828-FE18-3961-9430-A32SA07D7B91]: 0x2

If this is the case, you may want to delete the socket manually to fix it and try again.

Again, UNLOAD the daemon FIRST (just in case it is loaded):

sudo launchctl unload /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist

Remove the socket:

rm /var/run/mDNSResponder

Reset back to the default mDNSResponder options (with Bonjour):

sudo defaults write /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist ProgramArguments -array "/usr/sbin/mDNSResponder" "-launchd"

Try reloading the daemon again, it should work!

sudo launchctl load /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist