logo

scripts

A bunch of scripts, some to be moved to their own repository git clone https://hacktivis.me/git/scripts.git

unbound_opennic.sh (1219B)


  1. #!/bin/sh
  2. # Setup before launching:
  3. # You need to add an include directive to your main unbound configuration, like so:
  4. # echo 'include: /etc/unbound/unbound_opennic.conf' >> /etc/unbound/unbound.conf
  5. #
  6. # You can then launch the script like so: ./unbound_opennic.sh > /etc/unbound/unbound_opennic.conf
  7. #
  8. # Dependencies:
  9. # - POSIX shell (/bin/sh) and environment (printf, rm)
  10. # - curl: https://curl.haxx.se/
  11. # - jq: http://stedolan.github.io/jq/
  12. # List extracted from https://wiki.opennic.org/opennic/dot at 2019-09-24
  13. TLDS_current="bbs chan cyb dyn epic geek gopher indy libre neo null o oss oz parody pirate"
  14. TLDS_inactive="free"
  15. TLDS_peered="bazar coin emc lib fur ku te ti uu"
  16. TLDS="glue ${TLDS_current} ${TLDS_inactive} ${TLDS_peered}"
  17. curl 'https://api.opennicproject.org/geoip/?json&res=10&ipv=64&anon=true' > /tmp/opennic.json
  18. printf -- 'server:\n'
  19. for tld in ${TLDS}; do
  20. printf -- '\tdomain-insecure: "%s"\n' "$tld"
  21. done
  22. for tld in ${TLDS}; do
  23. printf -- '\nstub-zone:\n'
  24. printf -- '\tname: "%s"\n' "$tld"
  25. jq -r '.[] | "\tstub-host: "+.host+"."' < /tmp/opennic.json
  26. done
  27. jq -r '.[] | "\nforward-zone:\n\tname: \""+.host+"\" #("+.stat+"%)\n\tforward-addr: "+.ip' < /tmp/opennic.json
  28. rm /tmp/opennic.json