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
Signed by untrusted user who does not match committer: jdesroches
GPG Key ID: 6778C9C29C02D691
1 changed files with 34 additions and 0 deletions

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