keyfile=/opt/secret/bind/dynamic.orbekk.com/update/named.conf.key update() { local type="$1" shift local host="$1" shift local ip="$1" shift echo "Update $host to $ip ($type)" { echo server 2001:470:8e2e:20::d echo update delete ${host}. ${type} echo update add ${host}. 300 ${type} ${ip} echo send } | nsupdate -v -k "$keyfile" } ip_4="$(ip -br -4 addr list dev eno1 | awk -F' *|/' '{print $3}')" if [[ -n "$ip_4" ]]; then update A $(hostname).dynamic.orbekk.com $ip_4 fi # IPv6 currently broken on Spectrum :( # ip_6="$(ip -br -6 addr list scope global dev eno1 | awk -F' *|/' '{print $3}')" # if [[ -n "$ip_6" ]]; then # update AAAA $(hostname).dynamic.orbekk.com $ip_6 # fi