Created
August 11, 2013 02:16
-
-
Save jbartko/6203107 to your computer and use it in GitHub Desktop.
nscheck - check DNS A and PTR records against multiple nameservers.
This file contains 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
#!/bin/bash | |
# nscheck | |
# Author: John Bartko <jbartko@gmail.com> | |
NS1=$(grep nameserver /etc/resolv.conf | head -n 1 | awk '{print $2}') | |
NS2='8.8.8.8' | |
DIG=/usr/bin/dig | |
DIGOPTS='+noall +answer ' | |
USAGE=$(cat << 'EOUSAGE' | |
NAME\n | |
\tnscheck - check DNS A and PTR records against multiple nameservers.\n | |
\n | |
SYNOPSIS\n | |
\tnscheck -x IP\n | |
\tnscheck NAME\n | |
\tnscheck NAME -x IP -x IP NAME\n | |
\n | |
DESCRIPTION\n | |
\tPrints the results of a DNS query to multiple nameservers.\n | |
\n | |
\t-h\n | |
\t\tprint help\n | |
\n | |
\t-x\n | |
\t\tperform reverse lookup\n | |
EOUSAGE | |
) | |
function do_nscheck() { | |
sed -e :a -e 's/^.\{1,79\}$/&#/;ta' <<<"### [ NS1 $NS1 ] " | |
$DIG @$NS1 $DIGOPTS $@ | |
sed -e :a -e 's/^.\{1,79\}$/&#/;ta' <<<"### [ NS2 $NS2 ] " | |
$DIG @$NS2 $DIGOPTS $@ | |
echo | |
} | |
while getopts "hx" OPT; do | |
case $OPT in | |
h ) echo -e $USAGE | |
exit 0;; | |
x ) DIGOPTS="${DIGOPTS}-x " | |
shift;; | |
* ) exit 1;; | |
esac | |
done | |
do_nscheck | |
# vim: set ts=4 sw=4 et syn=sh: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment