Skip to content

Instantly share code, notes, and snippets.

@goofball222
Created November 29, 2018 23:26
Show Gist options
  • Save goofball222/4cb6aa5ae3209863dc41748bda9a4758 to your computer and use it in GitHub Desktop.
Save goofball222/4cb6aa5ae3209863dc41748bda9a4758 to your computer and use it in GitHub Desktop.
Script to download and format the https://github.com/StevenBlack hosts list for Unbound
#!/bin/bash
/usr/bin/curl -sSL https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts -o hosts1
cat hosts1 | awk '{ sub("\r$", ""); print }' | grep '^0\.0\.0\.0' | awk '{print $2}' | grep -v '^0\.0\.0\.0' > hosts1.clean
cat hosts1.clean \
| tr A-Z a-z \
| sort -u > hosts1.sort
comm -23 hosts1.sort ../unbound/whitelist.conf > clean
awk '{print "local-zone: \""$1"\" redirect\nlocal-data: \""$1" A 0.0.0.0\""}' clean > ../unbound/blocklist.conf
rm clean hosts*
docker restart unbound
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment