Skip to content

Instantly share code, notes, and snippets.

@mbierman
Created May 31, 2022 08:41
Show Gist options
  • Save mbierman/d99bc178379724b981a8dc3c7d24cc1f to your computer and use it in GitHub Desktop.
Save mbierman/d99bc178379724b981a8dc3c7d24cc1f to your computer and use it in GitHub Desktop.
test the speed of DNS servers
#!/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
@mbierman
Copy link
Author

mbierman commented Jun 5, 2022

Use

You can specify a test target or not

./dnsspeedtest.sh Firewalla.com

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,

./dnsspeedtest.sh | sort

Note: change the Unbound IP to be your Firewalla LAN.

Sample results

78CAFE74-0233-4E50-A36C-B4A4457FA50B

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment