forked from menandmice-services/dns-monitoring-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test16.sh
executable file
·47 lines (40 loc) · 1.41 KB
/
test16.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/sh
# Test 16 validates all records of a given domain using delv.
echo " == #16 - Delv zone validation == "
# Enter the IP of your authoritative nameserver
# zone transfers needs to be allowed for the system
# you're starting this script from
AUTHORITATIVE=""
if [ "$AUTHORITATIVE" = "" ]; then
AUTHORITATIVE=$(dig +short ${1} SOA | cut -d' ' -f1)
fi
unsigned=0
errornous=0
validated=0
ZONEDATA=$(dig -t axfr -q ${1} @${AUTHORITATIVE})
if echo "${ZONEDATA}" | grep -q "Transfer failed"; then
echo "Zone transfers disabled; Exiting..."
exit 1
fi
(echo "${ZONEDATA}" | grep -v "NSEC\|RRSIG\|DNSKEY\|^;\|^$" | awk '{ print $1,$4 }' | sort -u) |
{ while read -r domain rr; do
# mind that this will use your local resolver; so you
# need to make sure there are only dnssec-capable
# resolvers in your /etc/resolv.conf. Alternatively
# add @resolver-ip-address-or-hostname to the below cmd
out=$(delv +cdflag +nodnssec +nottl +noclass ${domain} ${rr});
state=$(echo "${out}" | head -n1);
if [ "${state}" = "; unsigned answer" ]; then
printf "Unsigned record: ";
unsigned=$((unsigned+1))
elif [ "${state}" != "; fully validated" ]; then
printf "Errornous record: ";
errornous=$((errornous+1))
else
printf "Validated record: ";
validated=$((validated+1))
fi
echo "$domain ($rr)";
done
echo "validated/unsigned/errors: $validated/$unsigned/$errornous";
}