Turn firewall on or off from Terminal

This command lets you turn the build in OS X firewall on and off, on both for specific services or essential services. It works with OS X 10.5, 10.6, 10.7 and 10.8. It also works via Apple Remote Desktop.

To turn the firewall off:

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

To turn the firewall on for specific applications/services:

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

To turn the firewall on for essential services like DHCP and ipsec, block all the rest:

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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s