Last active
December 30, 2020 06:27
-
-
Save jgoettsch/b859064bf8253dd813c87b6afd1e44eb to your computer and use it in GitHub Desktop.
Block malware with unbound on OpenBSD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/ksh | |
set -x | |
URL=https://mirror1.malwaredomains.com/files/domains.txt | |
OUTDIR=/tmp | |
OUT="$OUTDIR/domains.txt" | |
UNBOUND_ETC=/var/unbound/etc | |
MALWARE_CONF="$UNBOUND_ETC/malware.conf" | |
cd "$OUTDIR" && ftp "$URL" | |
if [ -f "$OUT" ] ; | |
then | |
grep -v "^#" "$OUT" | sort | awk '{print "local-zone: \""$1"\" redirect\nlocal-data: \""$1" A 0.0.0.0\""}' > "$MALWARE_CONF" | |
fi | |
test -e "$MALWARE_CONF" && rcctl reload unbound | |
rm "$OUT" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment