Created
May 31, 2022 08:41
-
-
Save mbierman/d99bc178379724b981a8dc3c7d24cc1f to your computer and use it in GitHub Desktop.
test the speed of DNS servers
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 | |
target="${1:-google.com}" | |
echo testing $target | |
main() | |
{ | |
# Enter the DNS providers you want to test | |
hosts='[ | |
{ | |
"name": "Cloudflare std", | |
"IP": "1.1.1.1" | |
}, | |
{ | |
"name": "Cloudflare Malware", | |
"IP": "1.1.1.2" | |
}, | |
{ | |
"name": "Google", | |
"IP": "8.8.8.8" | |
}, | |
{ | |
"name": "OpenDNS", | |
"IP": "208.67.222.222" | |
}, | |
{ | |
"name": "Quad9", | |
"IP": "9.9.9.9" | |
}, | |
{ | |
"name": "nextdns", | |
"IP": "45.90.28.22" | |
}, | |
{ | |
"name": "Unbound", | |
"IP": "192.168.0.1" | |
} | |
]' | |
echo $hosts | jq -c '.[]' | while read i; do | |
IP=$(echo $i | jq -r '.IP') | |
name=$(echo $i | jq -r '.name') | |
result=$(dig @${IP} ${target} | grep Query | cut -d":" -f2) | |
printf '%-20s %-10s\n' "$name:" "$result" | |
done | |
} | |
foo=$(main) | |
echo "$foo" | sort -n -t ':' -k2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use
You can specify a test target or not
If you don’t specify a test target,
google.com
is the default.This should run on Firewalla, macOS, or most Linux distros.
To sort the providers alphabetically,
Note: change the Unbound IP to be your Firewalla LAN.
Sample results