commit 6b854e62a3117a6d72002ef806f235c08812e594 parent b5d53e4b51ab812742d629f26101af6c6ad76c3a Author: parazyd <parazyd@dyne.org> Date: Thu, 16 Feb 2017 13:38:37 +0100 add dns blackhole script Diffstat:
A | blackholedns | | | 26 | ++++++++++++++++++++++++++ |
1 file changed, 26 insertions(+), 0 deletions(-)
diff --git a/blackholedns b/blackholedns @@ -0,0 +1,26 @@ +#!/bin/dash +# +# gets list to blackhole from http://someonewhocares.org/hosts/hosts +# +# example cronjob: every day at 15:33 +# 33 15 * * * /path/to/blackholedns > /etc/unbound/blackhole.dns +# unbound: +# include: "/etc/unbound/blackhole.dns" + + +urls="$(curl -s http://someonewhocares.org/hosts/hosts)" + +[ -n "$urls" ] || exit 1 + +tmpfile="$(mktemp)" + +printf "%s\n" "$urls" | grep -e '^127' | mawk '{print $2}'| tail -n+7 > $tmpfile + +while read line; do + printf "%s" "$line" \ + | grep -E '+([a-z]|[A-Z]|['.'])' \ + | sed 's/.*/local-zone: "&" redirect,local-data: "& A 127.0.0.1"/' \ + | tr ',' '\n' +done < "$tmpfile" + +rm -f "$tmpfile"