-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdnstest.sh
55 lines (49 loc) · 1.15 KB
/
dnstest.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
#
# Nameserver performance test
declare -A nameservers
declare -A results
declare -a tested_domains
nameservers[Telekom]="195.228.240.85"
nameservers[Digi]="193.110.56.1"
nameservers[UPC]="195.184.180.4"
nameservers[Google]="8.8.8.8"
nameservers[Quad9]="9.9.9.9"
nameservers[C.F.]="1.1.1.1"
nameservers[OpenDNS]="208.67.222.222"
nameservers[Norton]="199.85.126.20"
tested_domains=(
"index.hu"
"origo.hu"
"kuruc.info"
"mobile.de"
"bbc.co.uk"
"wired.co.uk"
"amd.com"
"arstechnica.com"
"cannondale.cn"
"ferrari.cn"
)
dns_header="\t"
testcase=10
for a_nameserver in "${!nameservers[@]}"; do
dns_header+="\t$a_nameserver"
done
echo -e "$dns_header"
for a_domain in "${tested_domains[@]}"; do
for a_nameserver in "${!nameservers[@]}"; do
sum=0
for (( i=1; i<=testcase; i++)); do
result=$(dig $a_domain @${nameservers[$a_nameserver]} \
| grep "Query time"\
| awk '{print $4}')
sum=$((result+sum))
done
results[$a_domain]+="$((sum/testcase))\t"
done
if [ ${#a_domain} -lt 8 ]; then
echo -e "$a_domain\t\t${results[$a_domain]}"
else
echo -e "$a_domain\t${results[$a_domain]}"
fi
done