Skip to content

Instantly share code, notes, and snippets.

@istefy
Forked from Rhynorater/getValidDNS.sh
Created September 21, 2018 23:25
Show Gist options
  • Save istefy/e6053d303146fc4827ecf6cd2f847e5c to your computer and use it in GitHub Desktop.
Save istefy/e6053d303146fc4827ecf6cd2f847e5c to your computer and use it in GitHub Desktop.
A little bash script to gather valid AND fast DNS Resolvers from public-dns.info
if [ "$#" -eq 0 ] || [ "$#" -gt 2 ] || [[ $* == *--help* ]] || [[ $* == *-h* ]]; then
echo "Usage ./getValidDNS.sh [output file] [optional: timeout (seconds)]"
exit 1
fi
if [ "$#" -eq 2 ]; then
timeout=$2
else
timeout=1
fi
rm us.txt
wget -q "https://public-dns.info/nameserver/us.txt"
for line in $(cat us.txt); do
if [[ $line =~ .*:.* ]]; then
continue
fi
result=$( dig +time=$timeout A localhost.rhynorater.com @$line )
if [[ $result =~ "127.0.0.1" ]]; then
echo "Valid: $line"
echo $line >> $1
else
echo "Invalid: $line"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment