Skip to content

Instantly share code, notes, and snippets.

@esolitos
Last active May 11, 2017 11:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save esolitos/679295a25d6b21ee262cd7fee20b2ace to your computer and use it in GitHub Desktop.
Save esolitos/679295a25d6b21ee262cd7fee20b2ace to your computer and use it in GitHub Desktop.
This will check the A record both for the provided NameServer and for the domain's own NameServer.
#!/bin/sh
#
# This will check the A record both for the provided NameServer
# and for the domain's specified NS
#
if [ "$1" = "--help" -o "$1" = "-h" ]; then
echo "\nUsage:"
echo "$0 \$NS_IP domain1.tld domain2.tld ..."
echo "Example: $0 8.8.8.8 google.com example.com\n"
return 0;
fi;
myNS="$1"
domains="${@:2}"
echo "Checking domains: $domains"
echo "Using as my NS: $myNS"
for dom in "$domains"; do
domNS="$(dig +short "$dom" NS | head -n1)"
if [ ! -z "$domNS" ]; then
echo "#\n#\tAsking for $dom\n#"
echo "\n NS: $names"
dig "@$domNS" +noall +answer "$dom" A
else
echo "\n#\tERROR: Missing domain name server or domain not existent"
fi
echo "\n Asking my NameServer"
dig +noall +answer "$dom" A
dig +noall +answer "www.$dom" A
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment