Neurohazard
暮雲煙月,皓首窮經;森羅萬象,如是我聞。

OS X 使用 terminal 关闭防火墙

wpadmin~May 11, 2020 /System Management

Contents

OS X 使用 terminal 关闭防火墙

正文

Table of Contents


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.

If you like this article, consider sponsoring me by trying out a Digital Ocean
VPS. With this link you’ll get $100 credit for 60 days). (referral link)

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    

参考

https://raymii.org/s/snippets/OS_X_-_Turn_firewall_on_or_off_from_the_command_line.html

Leave a Reply

Your email address will not be published. Required fields are marked *