unbound_opennic.sh (1219B)
- #!/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="glue ${TLDS_current} ${TLDS_inactive} ${TLDS_peered}"
- curl 'https://api.opennicproject.org/geoip/?json&res=10&ipv=64&anon=true' > /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