-
-
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
This file contains 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
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