Add script to check powerdns records.
This commit is contained in:
parent
8e4a52194c
commit
eb81c1306c
1 changed files with 34 additions and 0 deletions
34
check-dns.sh
Executable file
34
check-dns.sh
Executable 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
|
Loading…
Reference in a new issue