Skip to content

Instantly share code, notes, and snippets.

@jgoettsch
Last active December 30, 2020 06:27
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jgoettsch/b859064bf8253dd813c87b6afd1e44eb to your computer and use it in GitHub Desktop.
Save jgoettsch/b859064bf8253dd813c87b6afd1e44eb to your computer and use it in GitHub Desktop.
Block malware with unbound on OpenBSD
#!/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