From 9aaa640a8bd3d2043b5f4a77a2b444752af477a6 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 15 Aug 2024 13:39:44 +0200 Subject: [PATCH] Add script to generate dns entries from interface addresses --- dns-generate-for-device.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 dns-generate-for-device.sh diff --git a/dns-generate-for-device.sh b/dns-generate-for-device.sh new file mode 100644 index 0000000..85c8f61 --- /dev/null +++ b/dns-generate-for-device.sh @@ -0,0 +1,18 @@ +#!/bin/sh +# Nico Schottelius, 2024-08-14 +# +# Retrieve an IPv6 interface address and generate a generic +# DNS zone file + +if [ #$ -ne 3 ]; then + echo "$0 address interface hostname" + exit 1 +fi + +address=$1; shift +interface=$1; shift +hostname=$1; shift + +interface_addr=$(ssh "root@${address}" "ip -o a sh dev ${interface}" | awk '/inet6/ { print $4 }' | grep -v ^fe80| sed 's,/.*,,') + +echo "${hostname} AAAA ${interface_addr}"