Skip to content

Instantly share code, notes, and snippets.

@scottwallacesh
Created June 29, 2017 17:44
Show Gist options
  • Save scottwallacesh/d1ce003259272b52282701562a1dafae to your computer and use it in GitHub Desktop.
Save scottwallacesh/d1ce003259272b52282701562a1dafae to your computer and use it in GitHub Desktop.
Script for OpenWRT ad blocking
BLOCKADS=/etc/dnsmasq.d/blockads
CONF=/etc/dnsmasq.conf
cat - << EOF > ${CONF}
conf-dir=$(dirname ${BLOCKADS})
EOF
# Create the directory
mkdir -p $(dirname ${BLOCKADS})
# Fetch the List Of Evil™
(
/usr/bin/wget -q -O - "http://pgl.yoyo.org/adservers/serverlist.php?hostformat=nohtml&showintro=0&mimetype=plaintext" | while read LINE; do
echo "address=/${LINE}/127.0.0.1"
done
) > ${BLOCKADS}
# Whitelist some domains
sed -i '/scorecardresearch.com/d' ${BLOCKADS}
# Bounce!
/etc/init.d/dnsmasq reload
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment