commit: 914c3b36473377e27505117de67f194dc0dbda7d
parent: fb82af82cfb90425591a98e8c77eb04c673f047d
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Tue, 24 Sep 2019 22:01:45 +0200
shell/unbound_opennic.sh: New script
Diffstat:
1 file changed, 34 insertions(+), 0 deletions(-)
diff --git a/shell/unbound_opennic.sh b/shell/unbound_opennic.sh
@@ -0,0 +1,34 @@
+#!/bin/sh
+# Setup before launching:
+# You need to add an include directive to your main unbound configuration, like so:
+# echo 'include: /etc/unbound/unbound_opennic.conf' >> /etc/unbound/unbound.conf
+#
+# You can then launch the script like so: ./unbound_opennic.sh > /etc/unbound/unbound_opennic.conf
+#
+# Dependencies:
+# - POSIX shell (/bin/sh) and environment (printf, rm)
+# - curl: https://curl.haxx.se/
+# - jq: http://stedolan.github.io/jq/
+
+# List extracted from https://wiki.opennic.org/opennic/dot at 2019-09-24
+TLDS_current="bbs chan cyb dyn epic geek gopher indy libre neo null o oss oz parody pirate"
+TLDS_inactive="free"
+TLDS_peered="bazar coin emc lib fur ku te ti uu"
+TLDS="${TLDS_current} ${TLDS_inactive} ${TLDS_peered}"
+
+curl 'https://api.opennicproject.org/geoip/?json&res=10&ipv=64' > /tmp/opennic.json
+
+printf -- 'server:\n'
+for tld in ${TLDS}; do
+ printf -- '\tdomain-insecure: "%s"\n' "$tld"
+done
+
+for tld in ${TLDS}; do
+ printf -- '\nstub-zone:\n'
+ printf -- '\tname: "%s"\n' "$tld"
+jq -r '.[] | "\tstub-host: "+.host+"."' < /tmp/opennic.json
+done
+
+jq -r '.[] | "\nforward-zone:\n\tname: \""+.host+"\" #("+.stat+"%)\n\tforward-addr: "+.ip' < /tmp/opennic.json
+
+rm /tmp/opennic.json