Skip to content

Instantly share code, notes, and snippets.

@Rhynorater
Created September 9, 2018 22:32
Show Gist options
  • Save Rhynorater/6d84748cb4d73f8d878c3c4a86e2c383 to your computer and use it in GitHub Desktop.
Save Rhynorater/6d84748cb4d73f8d878c3c4a86e2c383 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