Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
filterlists for unbound in opnsene. Services: Unbound DNS: General > Custom options > include:/var/unbound/ad-blacklist.conf
echo "Removing old files..."
[ -f /tmp/hosts.working ] && rm -f /tmp/hosts.working
blacklist=' '
for url in $blacklist; do
curl --silent $url >> "/tmp/hosts.working"
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\"\n", $1}' | sed '/ A { 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