diff options
-rwxr-xr-x | tools/update-dns.sh | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tools/update-dns.sh b/tools/update-dns.sh new file mode 100755 index 0000000..bce4de4 --- /dev/null +++ b/tools/update-dns.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +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 dragon.orbekk.com + 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}')" +update A $(hostname).dynamic.orbekk.com $ip_4 |