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}"