Created
January 11, 2020 14:48
-
-
Save freuds/a701ba9d55df2a152706aeb62a31053c to your computer and use it in GitHub Desktop.
Check zone DNSSEC
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
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 | { | |
# Check each delegated name server | |
while read DOMAIN TYPE NS | |
do | |
if [ "$DOMAIN $TYPE" != "$ZONE NS" ] | |
then | |
continue | |
fi | |
NO_NS=false | |
if dig +cd +dnssec +norecurse DNSKEY "$ZONE" "@$NS" | | |
egrep '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 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment