Last active
August 29, 2015 14:00
-
-
Save sahal/317bb8dca6719776e10f to your computer and use it in GitHub Desktop.
Original versions of https://github.com/sahal/auto_verify_dns
This file contains hidden or 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 | |
| # ./auto_verify_dns.sh | |
| # _very_ dumb way to verify that a list of dns servers work... | |
| # by sahal | |
| # | |
| # use: ./auto_verify_dns.sh /full/path/to/dns/servers > ~/output | |
| # requires timeout3 (set $W_TOUT) by Dimitry V Golovashkin (see Google) | |
| # path to timeout3 - written by Dmitry V Golovashkin - via google | |
| W_TOUT=/home/sahal/scripts/others/timeout3 | |
| fullpath_to_list_of_dns_servers=$1 | |
| #output=$2 | |
| a=($(cat $fullpath_to_list_of_dns_servers)) | |
| for i in $(seq 0 $((${#a[@]} - 1))) | |
| do | |
| $W_TOUT -t 5 nslookup baidu.com ${a[$i]} | grep answer\: > /dev/null 2>&1 | |
| if [ $? -eq 0 ]; then | |
| echo ${a[$i]} #>> $output | |
| fi | |
| done |
This file contains hidden or 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 | |
| # ./auto_verify_dns.sh [server 10.0.0.12] | |
| # desc: a quick test to see if a list (or one) of nameservers (IP/domains) | |
| # are able to resolve a particular $domain within a set $timeoutsec | |
| # by: Sahal Ansari (github@sahal.info) | |
| # todo: check if nameserver given is a valid IP, print timeout lengths | |
| #pick a domain to resolve (e.g. yahoo.com or google.com) and put it here: | |
| domain=change.this.to.something.local | |
| # full path to timeout3 | |
| # https://github.com/jeuneS2/lemberg/blob/master/timeout3 | |
| timeout3=/home/user/timeout3.sh | |
| timeoutsec=5 | |
| # a list of potential dns servers | |
| dns=/home/user/listodnsservers | |
| if [ ! -e $timeout3 ]; then | |
| echo "OOps, You don't have timeout3" | |
| echo "Get it: https://github.com/jeuneS2/lemberg/blob/master/timeout3" | |
| exit 1 | |
| fi | |
| function checkdns { | |
| $timeout3 -t $timeoutsec nslookup $domain $1 > /dev/null 2>&1 && echo $1 | |
| } | |
| function breaklist { | |
| if [ ! -e "$dns" ]; then | |
| echo "OOps, Cannot find your list of DNS servers!?" | |
| exit 1 | |
| fi | |
| # you can mess with the input file (or not) | |
| # for server in $(cut -d, -f2 < $dns) | |
| for server in $(cat $dns) | |
| do | |
| checkdns $server | |
| done | |
| } | |
| case $1 in | |
| server*) | |
| checkdns $2 | |
| ;; | |
| *) | |
| breaklist | |
| ;; | |
| esac |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See the updated version on my github: https://github.com/sahal/auto_verify_dns