Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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