Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@seraphyn
Created October 16, 2018 06:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seraphyn/cc4ab8062ce71f14a4793c8200382c4f to your computer and use it in GitHub Desktop.
Save seraphyn/cc4ab8062ce71f14a4793c8200382c4f to your computer and use it in GitHub Desktop.
filterlists for unbound in opnsene. Services: Unbound DNS: General > Custom options > include:/var/unbound/ad-blacklist.conf
#!/bin/sh
echo "Removing old files..."
[ -f /tmp/hosts.working ] && rm -f /tmp/hosts.working
whitelist='/(api.solvemedia.com)/'
blacklist='https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/spy.txt https://ransomwaretracker.abuse.ch/downloads/RW_DOMBL.txt https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts http://sysctl.org/cameleon/hosts https://adaway.org/hosts.txt http://hosts-file.net/ad_servers.txt http://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&mimetype=plaintext '
for url in $blacklist; do
curl --silent $url >> "/tmp/hosts.working"
done
echo "Processing Blacklist..."
awk -v whitelist="$whitelist" '$1 ~ /^127\.|^0\./ && $2 !~ whitelist {gsub("\r",""); print tolower($2)}' /tmp/hosts.working | sort | uniq | \
awk '{printf "server:\n", $1; printf "local-data: \"%s A 0.0.0.0\"\n", $1}' | sed '/www.msedge.net########################################################################## A 0.0.0.0/ { N; d; }' > /var/unbound/ad-blacklist.conf
echo "Cleaning Up..."
rm -f '/tmp/hosts.working'
echo "Done. I Restart the DNS Resolver service"
service unbound onerestart
sleep 8
service unbound onestatus
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment