LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Speed test for a list of DNS addresses (https://www.linuxquestions.org/questions/linux-newbie-8/speed-test-for-a-list-of-dns-addresses-4175551411/)

Hoxygen232 08-22-2015 01:51 AM

Speed test for a list of DNS addresses
 
Hi,

I'm writing a unix script, I need a way to test the response time of a group of IP addresses (they are DNS addresses).
I was thinking I could you
Code:

dig google.com @[DNS_1]
but I should use it in a loop and I should get the
Code:

Query time:
in the result string and I don't know how to do that.

It would be nice if the script was able to get the DNS list from a simple file where each row is a DNS address.

How can I do that? Do you have any other idea?

Thanks

teckk 08-22-2015 09:58 AM

Code:

#! /usr/bin/env bash

#Add/subtract DNS here.
list=(
208.67.222.222        #OpenDNS
208.67.220.220        #OpenDNS
8.8.8.8                #Google
8.8.4.4                #Google
209.244.0.3        #Level3
209.244.0.4                #Level3
68.94.156.1        #ATT
68.94.157.1                #ATT
4.2.2.1                #Verizon
4.2.2.2                #Verizon
4.2.2.3                        #Verizon
4.2.2.4                #Verizon
4.2.2.5                #Verizon
4.2.2.6                        #Verizon
75.75.76.76                #Comcast
84.200.69.80        #DNSwatch
84.200.70.40        #DNSwatch
209.88.198.133        #Greenteam
195.46.39.39        #SafeDNS
195.46.39.40        #SafeDNS
50.116.23.211        #OpenNIC
37.235.1.174        #FreeDNS
37.235.1.177        #FreeDNS
8.26.56.26                #Comodo
8.20.247.20                #Comodo
74.82.42.42                #Hurricane
89.233.43.71        #Censur
91.239.100.100        #Censur
)

for i in ${list[@]}; do
        echo $i
        dig @"$i" bing.com | grep Query
        sleep 1
        echo ''
done > dnstest.txt


Hoxygen232 08-22-2015 10:34 AM

thanks


All times are GMT -5. The time now is 11:54 PM.