How to or Is that possible to stop mDNSResponder without disable System Integrity Protection

dnslaunchd

I have tried the following:

$ sudo killall -HUP mDNSResponder
$ sudo killall -9 mDNSResponderHelper mDNSResponder
$ 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

None of them stop mDNSResponder from running.

Why do I want to do this? I just want to stop it before closing the lid. Because this stupid app is waking up my system when my lid remains closed. I tried many ways to avoid it running when system is at sleep. But none of them works. So the best option is just to force kill it and re-run it later. Thanks a lot.

Btw, this is not a XY question. I mean I want to stop it. The above explanation is just to clarify the reason why I want to do it, otherwise, people may ask why I want to do it and ask me not to do. Well, I really want to stop it and this is the question. The app is 100% useless to me when my system is at sleep and my lid is closed. Thanks.

Best Answer

You cannot unload mDNSResponder on a standard setup with SIP enabled. You will have to disable SIP from Recovery mode in order to be able to do so.

I would not recommend running with SIP permanently disabled, which would be necessary if you want to periodically unload/load mDNSResponder with launchctl. So if you really want to do this (relatively obscure) thing, then I suggest permanently unloading the launch daemon, and then manually starting/stopping mDNSResponder as needed. The latter can be done with SIP enabled.

A different way to approach the issue, assuming that network traffic is the cause of the wakes, could be to let mDNSResponder run all the time, and use the built-in firewall pf to block all traffic from mDNSResponder before going to sleep, and removing the block after it wakes.

Yet another could be to take a look at the IOPlatformFeatureDefaults and check if TCPKeepAliveDuringSleep is enabled, and try disabling that. It could fix your problem potentially. You can find more information on how to do that here:

https://discussions.apple.com/message/30869802#30869802