Block Facebook and Twitter with openWRT

Alex, November 17, 2015 11:56
I don't use Facebook. Yet Facebook still likes to track my movements around the internet. I can send do-not-track-me headers. I can install Privacy Badger (you should too). But what I ended up doing is blocking all traffic to the Facebook Autonomous Systems on my border firewall.
#!/bin/sh
#
# This script will reject all traffic to the Twitter and Facebook
# autonomous systems.
#
# (c) 2015 by @HackPending
TWITTER="AS54888 AS13414 AS35995"
FACEBOOK="AS63293 AS32934"
for NET in ${TWITTER} ${FACEBOOK}
do
  QUERY="!g${NET}"
  for IP in `whois -h whois.radb.net $QUERY | grep "/"`
  do
    iptables -I FORWARD 1 -p all -d "${IP}" -j REJECT
    iptables -I OUTPUT 1 -p all -d "${IP}" -j REJECT
  done
done
Feel free to use/change as needed. This script also blocks traffic to the twitterverse.