Created
August 21, 2018 23:32
-
-
Save Flushot/4707cbf1f0a10012af044905d2271c2c to your computer and use it in GitHub Desktop.
Block IP addresses with macOS/BSD PF firewall
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Blocks list of IP addresses using macOS/BSD PF firewall. | |
# | |
# Enable: sudo pfctl -ef ./pf_block.conf | |
# | |
# Disable: sudo pfctl -d (completely disable firewall) | |
# sudo pfctl -f /etc/pf.conf (reset rules) | |
# | |
blocked_ips = "{ \ | |
1.2.3.4 \ | |
5.6.7.8 \ | |
}" | |
set block-policy return | |
block out proto tcp to { $blocked_ips } port { 80, 443 } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment