Last active
March 27, 2018 06:05
-
-
Save leonboot/0ea599d5b0a27787e2a5b3e31755a574 to your computer and use it in GitHub Desktop.
Block and unblock all Facebook IP addresses on macOS (using pfctl, so it might work on BSD as well)
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
#!/bin/bash | |
( \ | |
echo -n "table <facebook> persist { "; \ | |
whois -h whois.radb.net '!gAS32934' | tail -n 2 | head -n 1 | sed 's/\ /,\ /g' | tr -d '\n'; \ | |
echo -n ', '; \ | |
whois -h whois.radb.net '!6AS32934' | tail -n 2 | head -n 1 | sed 's/\ /, /g' | tr -d '\n'; \ | |
echo ' }'; \ | |
echo "block quick to <facebook>" \ | |
) | sudo pfctl -f - | |
sudo pfctl -E |
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
#!/bin/bash | |
sudo pfctl -t facebook -T kill | |
sudo pfctl -F rules |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This script looks up all IPv4 and IPv6 ranges in use by Facebook, adds them to a PF table and blocks traffic to addresses in that table. Unblocking is done by removing the table and flushing all rules, so use at your own discretion, should you have other PF rules in place!