Last Updated: February 25, 2016
·
322
· pasine

Set Block all incoming connection via command line

I don't like to have any open port when I am connected to a public WiFi, so I usually turn on the Block all incoming settings from the Firewall preferences.

Here is a way to set/unset it via command line.

Set

sudo defaults write /Library/Preferences/com.apple.alf globalstate -int 2

Unset

sudo defaults write /Library/Preferences/com.apple.alf globalstate -int 1

Bear in mind that the Preferences Panel must be closed to apply this change.

I also created a workflow to set/unset this option via Alfred.