Skip to content

Instantly share code, notes, and snippets.

@scottwallacesh
Created June 29, 2017 08:29
Show Gist options
  • Save scottwallacesh/b90efd82f214f9dd7a5d3e04ff71a92c to your computer and use it in GitHub Desktop.
Save scottwallacesh/b90efd82f214f9dd7a5d3e04ff71a92c to your computer and use it in GitHub Desktop.
Block ads using dnsmasq
#!/bin/bash
BLOCKADS=/etc/dnsmasq.d/blockads
# Create the directory
mkdir -p $(dirname ${BLOCKADS})
# Fetch the List Of Evil™
/bin/curl -sq "http://pgl.yoyo.org/adservers/serverlist.php?hostformat=nohtml&showintro=0&mimetype=plaintext" | /bin/xargs -n1 -I@ echo "address=/@/127.0.0.1" > ${BLOCKADS}
# Whitelist some domains
sed -i '/scorecardresearch.com/d' ${BLOCKADS}
# Bounce!
systemctl restart dnsmasq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment