Difference between revisions of "Adig"
From James Dooley's Wiki
(→Overview) |
|||
| (5 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
| + | [[Category:Scripts]] | ||
==Overview== | ==Overview== | ||
| − | Advanced dig script that queries default name server on your workstation, google and name servers returned by dig. | + | Advanced dig script that queries default name server on your workstation, google, the liquidweb name server and name servers returned by dig (/registrar). |
Good for finding differences being reported by different name servers. | Good for finding differences being reported by different name servers. | ||
| Line 14: | Line 15: | ||
==Installation== | ==Installation== | ||
| − | < | + | <source lang='bash'> |
| − | wget http:// | + | wget http://scripts.ent.liquidweb.com/adig -O /usr/bin/adig && chmod +x /usr/bin/adig |
| − | </ | + | </source> |
==Usage== | ==Usage== | ||
| − | < | + | <source lang='bash'> |
adig site.com | adig site.com | ||
| − | </ | + | </source> |
==Script== | ==Script== | ||
| − | < | + | <source lang='bash'> |
#!/bin/bash | #!/bin/bash | ||
OIFS=$IFS;IFS=$'\n' | OIFS=$IFS;IFS=$'\n' | ||
| Line 33: | Line 34: | ||
#$1 Title | #$1 Title | ||
#$2 Message | #$2 Message | ||
| − | echo -e "\e[01;32m=== $1 ===\e[0m" | + | echo -e "\t\e[01;32m=== $1 ===\e[0m" |
for r in $(echo "$2") | for r in $(echo "$2") | ||
do | do | ||
| Line 77: | Line 78: | ||
} | } | ||
| − | + | function getdigns { | |
| − | + | #$1 domain | |
| − | + | digresult=`dig +noall +authority $1 | awk '{print $5}'` | |
| + | cleaned=`echo "$digresult" | grep -v "<<>>" | grep -ve "^;;" | sed "/^$/d" | sort | sed "s/\.$//"` | ||
| + | echo "${cleaned,,}" | ||
| + | } | ||
| + | |||
| + | function printusage { | ||
| + | echo "Return dig results from several different name servers" | ||
| + | echo "Usage: adig DOMAIN" | ||
| + | } | ||
| − | + | if [ ! -n "$1" ] | |
| − | + | then | |
| + | printusage | ||
| + | exit | ||
| + | fi | ||
| − | printresults " | + | printresults "Digging against resolv.conf" "`getdig $1`" |
| − | printresults " | + | printresults "Digging against liquidweb.com" "`getdig $1 'ns.liquidweb.com'`" |
| − | printresults " | + | printresults "Digging against google.com" "`getdig $1 '8.8.8.8'`" |
| − | for i in $( | + | for i in $(getdigns $1) |
do | do | ||
| − | + | printresults "Digging against $i" "`getdig $1 $i`" | |
| − | printresults "Digging against $i" "$ | ||
done | done | ||
IFS=$OIFS | IFS=$OIFS | ||
| − | </ | + | </source> |
Latest revision as of 14:30, 25 March 2014
Contents
Overview
Advanced dig script that queries default name server on your workstation, google, the liquidweb name server and name servers returned by dig (/registrar).
Good for finding differences being reported by different name servers.
Searching for main domain will return all record types (A,MX,TXT,NS,CNAME etc).
Searching for subdomain will generally only return CNAME and A records.
Color codes records for easier viewing.
This should not be installed on customer servers
Installation
wget http://scripts.ent.liquidweb.com/adig -O /usr/bin/adig && chmod +x /usr/bin/adig
Usage
adig site.com
Script
#!/bin/bash
OIFS=$IFS;IFS=$'\n'
function printresults {
#$1 Title
#$2 Message
echo -e "\t\e[01;32m=== $1 ===\e[0m"
for r in $(echo "$2")
do
echo -e "`colorresult $r`"
done
}
function colorresult {
rtype=`echo "$1" | awk '{print $4}'`
case $rtype in
A)
echo "\e[0;32m`echo "$1"`\e[0m"
;;
MX)
echo "\e[0;31m`echo "$1"`\e[0m"
;;
TXT)
echo "\e[0;34m`echo "$1"`\e[0m"
;;
NS)
echo "\e[0;36m`echo "$1"`\e[0m"
;;
CNAME)
echo "\e[0;35m`echo "$1"`\e[0m"
;;
*)
echo "$1"
;;
esac
}
function getdig {
#$1 domain
#$2 against
if [ -n "$2" ]
then
digresult=`dig $1 ANY +noall +answer @$2`
else
digresult=`dig $1 ANY +noall +answer`
fi
cleaned=`echo "$digresult" | grep -v "<<>>" | grep -ve "^;;" | sed "/^$/d" | sort -k 4`
echo "$cleaned"
}
function getdigns {
#$1 domain
digresult=`dig +noall +authority $1 | awk '{print $5}'`
cleaned=`echo "$digresult" | grep -v "<<>>" | grep -ve "^;;" | sed "/^$/d" | sort | sed "s/\.$//"`
echo "${cleaned,,}"
}
function printusage {
echo "Return dig results from several different name servers"
echo "Usage: adig DOMAIN"
}
if [ ! -n "$1" ]
then
printusage
exit
fi
printresults "Digging against resolv.conf" "`getdig $1`"
printresults "Digging against liquidweb.com" "`getdig $1 'ns.liquidweb.com'`"
printresults "Digging against google.com" "`getdig $1 '8.8.8.8'`"
for i in $(getdigns $1)
do
printresults "Digging against $i" "`getdig $1 $i`"
done
IFS=$OIFS