diff options
author | Kjetil Ørbekk <kj@orbekk.com> | 2020-10-31 14:08:02 -0400 |
---|---|---|
committer | Kjetil Ørbekk <kj@orbekk.com> | 2020-11-08 18:23:59 -0500 |
commit | d37a4f11e1ff414f2e9fccf4316a99d914934279 (patch) | |
tree | 1a15d346da7f1214ddc2dbda5762d58fa3501a3d | |
parent | 90b751e55eab56567723c64cfc3c6b1b6d10132a (diff) |
Add dynamic ip script
-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 |