Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I can use the Security & Privacy preference pane to enable and disable the firewall, but how can I do it with the command line - something with defaults write maybe?


share|improve this question
up vote 9 down vote accepted

Enable the application firewall via

defaults write /Library/Preferences/ globalstate -int 1

(0 to disable), and restart the services

launchctl unload /System/Library/LaunchAgents/
launchctl unload /System/Library/LaunchDaemons/

launchctl load /System/Library/LaunchDaemons/
launchctl load /System/Library/LaunchAgents/

The application firewall can be controlled with the /usr/libexec/ApplicationFirewall/socketfilterfw binary.

See here for further information.

Note that the application firewall is entirely different from the BSD packet filter, that can be configured with the ipfw command line utility.

share|improve this answer
You need to sudo the unload & load of the daemon (/System/Library/LaunchDaemons/; otherwise it'll try to unload & load them from the user launchd, which won't work right. Do not, however, sudo the commands for the useragent. – Gordon Davisson Sep 10 '12 at 13:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .