Author Topic: Shell Script to Test Your ISP versus OpenDNS and Google DNS  (Read 286 times)

Offline scotbuff

  • Sys Admin
  • UNIX User
  • *****
  • Posts: 174
  • Karma: +2/-0
    • View Profile
    • Scott.Buffington.me
Shell Script to Test Your ISP versus OpenDNS and Google DNS
« on: February 17, 2010, 08:47:40 am »
Here is a shell script to test the lookup speeds of several domain names using your current ISP DNS versus OpenDNS and Google DNS.  The script uses dig to test the speeds.  It should be easy enough for you to add additional DNS services or change the domain names or the websites. 
Code: [Select]
#!/bin/bash
isp=$(dig +noall +stats 2>&1 | awk '$2~/^SERVER:$/{split($3,dnsip,"#");print dnsip[1]}');
m="-------------------------------------------------------------------------------";
s="                                                                               ";
h="+${m:0:25}+${m:0:12}+${m:0:12}+${m:0:12}+";
header=("Domain${s:0:23}" "My ISP${s:0:10}" "Google${s:0:10}" "OpenDNS${s:0:10}");
echo "${h}";
echo "| ${header[0]:0:23} | ${header[1]:0:10} | ${header[2]:0:10} | ${header[3]:0:10} |";
echo "${h}";
for i in "yahoo.com" "identi.ca" "twitter.com"  "brutaldeluxe.us" "google.com" "bbc.co.uk" "scott.buffington.me";
do
  ii="${i}${s:23}";
  echo -n "| ${ii:0:23} |";
  for j in "${isp}"  "8.8.8.8"  "208.67.222.222";
  do
    r="${s:10}$(dig +noall +stats +time=9 @${j} ${i} 2>&1 | awk '$2~/^Query$/{print $4" "$5}')";
    echo -n " ${r:${#r}-10} |";
  done
  echo -ne "\n${h}\n";
done