Difference between revisions of "Adig"
(→Installation) |
(→Script) |
||
| Line 33: | Line 33: | ||
#$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 77: | ||
} | } | ||
| − | function | + | function getdigns { |
| − | #$domain | + | #$1 domain |
digresult=`dig +noall +authority $1 | awk '{print $5}'` | digresult=`dig +noall +authority $1 | awk '{print $5}'` | ||
| − | cleaned=`echo "$digresult" | grep -v "<<>>" | grep -ve "^;;" | sed "/^$/d" | sort` | + | cleaned=`echo "$digresult" | grep -v "<<>>" | grep -ve "^;;" | sed "/^$/d" | sort | sed "s/\.$//"` |
| − | echo "$cleaned" | + | 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 | ||
</code> | </code> | ||
Revision as of 18:29, 11 February 2012
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
[bash,n]
wget http://scripts.ent.liquidweb.com/adig -O /usr/bin/adig && chmod +x /usr/bin/adig
Usage
[bash,n]
adig site.com
Script
[bash,n]
- !/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