You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.7 KiB

  1. #
  2. #.Distributed under the terms of the GNU General Public License (GPL) version 2.0
  3. #
  4. # The script directly updates a PowerDNS (or maybe bind server) via nsupdate from bind-client package.
  5. #.based on github request #957 by Jan Riechers <de at r-jan dot de>
  6. #.2015 Christian Schoenebeck <christian dot schoenebeck at gmail dot com>
  7. #
  8. # This script is parsed by dynamic_dns_functions.sh inside send_update() function
  9. #
  10. # using following options from /etc/config/ddns
  11. # option username - keyname
  12. # option password - shared secret (base64 encoded)
  13. # option domain - full qualified domain to update
  14. # option dns_server - DNS server to update
  15. #
  16. # variable __IP already defined with the ip-address to use for update
  17. #
  18. local __TTL=600 #.preset DNS TTL (in seconds)
  19. local __RRTYPE __PW __TCP
  20. local __PROG=$(which nsupdate) # BIND nsupdate ?
  21. [ -z "$__PROG" ] && __PROG=$(which knsupdate) # Knot nsupdate ?
  22. [ -z "$__PROG" ] && write_log 14 "'nsupdate' or 'knsupdate' not installed !"
  23. [ -z "$username" ] && write_log 14 "Service section not configured correctly! Missing 'username'"
  24. [ -z "$password" ] && write_log 14 "Service section not configured correctly! Missing 'password'"
  25. [ -z "$dns_server" ] && write_log 14 "Service section not configured correctly! Missing 'dns_server'"
  26. [ $use_ipv6 -ne 0 ] && __RRTYPE="AAAA" || __RRTYPE="A"
  27. [ $force_dnstcp -ne 0 ] && __TCP="-v" || __TCP=""
  28. # create command file
  29. cat >$DATFILE <<-EOF
  30. server $dns_server
  31. key $username $password
  32. update del $domain $__RRTYPE
  33. update add $domain $__TTL $__RRTYPE $__IP
  34. show
  35. send
  36. answer
  37. quit
  38. EOF
  39. $__PROG -d $__TCP $DATFILE >$ERRFILE 2>&1
  40. # nsupdate always return success
  41. write_log 7 "(k)nsupdate reports:\n$(cat $ERRFILE)"
  42. return 0