Add script to check powerdns records.

This commit is contained in:
Joachim Desroches 2022-10-20 11:48:20 +02:00
parent 8e4a52194c
commit eb81c1306c
No known key found for this signature in database
GPG key ID: 6778C9C29C02D691

34
check-dns.sh Executable file
View file

@ -0,0 +1,34 @@
#!/bin/sh
# Script to download a list of records setup in PowerDNS and ping the linked A
# and AAAA addresses, printing out those that do not answer. This allows to
# find and clean legacy records. Written by sparrowhawk at work, anno domini
# 2022.
FILE=rc-records.txt
ssh pdns.lnth.ch.recycled.cloud 'pdnsutil list-all-zones | while read -r zone; do pdnsutil list-zone $zone; done' >$FILE
echo "IPv4:"
awk '/.*\sA\s.*/ { print $1, $5 }' $FILE | sort | while read -r record;
do
host=$(echo "$record" | cut -f1 -d' ')
addr=$(echo "$record" | cut -f2 -d' ')
if ! ping -c1 "$addr" >/dev/null;
then
echo "$host INEXISTANT"
fi
done
echo "IPv6:"
awk '/.*\sAAAA\s.*/ { print $1, $5 }' $FILE | sort | while read -r record;
do
host=$(echo "$record" | cut -f1 -d' ')
addr=$(echo "$record" | cut -f2 -d' ')
if ! ping -c1 "$addr" >/dev/null;
then
echo "$host INEXISTANT"
fi
done