Created
August 9, 2022 07:28
-
-
Save nobiit/df023f0f0171ece79f8ceb58cd48e277 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env bash | |
set -e | |
DNS_SERVER=${1} | |
DOMAIN=${2:-google.com} | |
COUNT=${3:-100} | |
printf "Testing DNS for %s on %s ...\n" ${DOMAIN} ${DNS_SERVER} | |
for _ in $(seq 1 ${COUNT}); do | |
start_time=$(date +'%s') | |
result=$(dig ${DOMAIN} @${DNS_SERVER} || true) | |
end_time=$(date +'%s') | |
time=$(expr ${end_time} - ${start_time} || true) | |
echo $(echo "${result}" | grep -oP ';; Query time: \K([0-9]+) msec') "${time}s" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment