-
Notifications
You must be signed in to change notification settings - Fork 0
/
dchk.sh
executable file
·50 lines (34 loc) · 955 Bytes
/
dchk.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
48
49
50
checksigned() {
ZONE=$(basename "$1" .).
if [ "${ZONE}" = .. ]; then
ZONE=.
fi
NAME=$(basename "${ZONE}" .)
NO_NS=true
NO_SEC=false
OPTS="+cd +noall +answer +nocl +nottl"
dig "${OPTS}" NS "${ZONE}" @publicdns.goog | {
while read -r DOMAIN TYPE NS; do # Check each delegated name server
if [ "${DOMAIN} ${TYPE}" != "${ZONE} NS" ]; then
continue
fi
NO_NS=false
if dig +cd +dnssec +norecurse DNSKEY "${ZONE}" "@${NS}" | grep -E 'RRSIG[[:space:]]+DNSKEY' > /dev/null; then
echo "${NS} has DNSSEC data for ${NAME}"
else
echo "${NS} does not have DNSSEC data for ${NAME}"
NO_SEC=true
fi
done
if "$NO_NS"; then
echo "${NAME} is not a delegated DNS zone"
else
if "${NO_SEC}"; then
return
fi
MINTTL=$(dig +cd SOA "${ZONE}" @publicdns.goog | awk '/^[^;]/ && $4=="SOA" { print $11 }')
echo "Negative cache for ${NAME} expires after ${MINTTL} seconds."
fi
}
}
checksigned "$1"