summaryrefslogtreecommitdiff
path: root/tools/update-dns.sh
blob: e5a5d64b8dc307d06fa868c4afaa9065f2c2a4a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
keyfile=/opt/secret/bind/dynamic.orbekk.com/update/named.conf.key
INTERFACE=wan-vport

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 netns exec router ip -br -4 addr list dev ${INTERFACE} | awk -F' *|/' '{print $3}')"
if [[ -n "$ip_4" ]]; then
  update A $(hostname).dynamic.orbekk.com $ip_4
  update A gw.dynamic.orbekk.com $ip_4
fi
ip_6="2001:470:8e2e:20::d"
#ip_6="$(ip -br -6 addr list scope global dev ${INTERFACE} | awk -F' *|/' '{print $3}')"
if [[ -n "$ip_6" ]]; then
  update AAAA $(hostname).dynamic.orbekk.com $ip_6
  update AAAA gw.dynamic.orbekk.com "2001:470:1f06:1194::2"
fi