Control Firewall from a Script or Command Line
There are a lot of searchable answers for controlling the firewall from the command line or a script out there, but none of them work in Mac OSX High Sierra. This suggestion is one such example. You can even change the integer passed to enable the firewall ("1") or block everything ("2"). Changes made via this command are reflected in the System Preferences user interface, but they are not made active. This is testable by using simple things such as ping, etc.
The same link above suggests that the firewall service/daemon needs to be restarted in order for these changes to take effect, but those commands do not work. Running
returns /System/Library/LaunchDaemons/com.apple.alf.agent.plist: Operation not permitted while System Integrity Protection is engaged. There are articles out there that discuss how to turn off system integrity protection too, but that seems like overkill something as simple as this.sudo launchctl unload /System/Library/LaunchDaemons/com.apple.alf.agent.plist
Does anyone have further ideas about how to 'restart' the firewall without all of this hassle?