Compare commits

...

2 Commits

Author SHA1 Message Date
Joachim Desroches 8fbc63d79b
shellcheck nextcloud file cleaning script 2022-10-20 11:48:59 +02:00
Joachim Desroches eb81c1306c
Add script to check powerdns records. 2022-10-20 11:48:59 +02:00
2 changed files with 35 additions and 1 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

View File

@ -18,7 +18,7 @@ while IFS= read -rd '' file <&3; do
printf ' s - Skip\n'
while true; do
read -p "? " -n1 ans
read -r -p "? " -n1 ans
printf '\n'
if [[ $ans = [0-9] && ${enc[ans]} ]]; then
name=$(iconv -f "${enc[ans]}" <<< "$base")