Skip to content

Instantly share code, notes, and snippets.

@bonnee
Created August 22, 2020 13:11
Show Gist options
  • Save bonnee/6780118526e589dd77b798a5975bcfbe to your computer and use it in GitHub Desktop.
Save bonnee/6780118526e589dd77b798a5975bcfbe to your computer and use it in GitHub Desktop.
dnsbench.sh: DNS resolver benchmark utility
#!/bin/zsh
RANK_URL="https://moz.com/top-500/download/?table=top500Domains"
echo "Downloading domain list..."
list=$(curl -fsSL "$RANK_URL" | awk -F, '{if (NR!=1) print $2}')
sum=0
while read line;
do
ms=$(drill @"$1" TXT "$line" | grep msec | awk '{print $4}')
i=$((i+1))
sum=$((ms+sum))
echo -e "\e[1A\e[K$i"
done < <(echo $list)
echo "Average resolving time: "$((sum/i))"ms"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment