Skip to content

Instantly share code, notes, and snippets.

Created September 18, 2014 22:55
Show Gist options
  • Select an option

  • Save anonymous/0beccd600d2f4f767d12 to your computer and use it in GitHub Desktop.

Select an option

Save anonymous/0beccd600d2f4f767d12 to your computer and use it in GitHub Desktop.
DNS Benchmark for German DNS Servers
#!/usr/bin/env perl -w
use strict;
my $SERVERLIST = '8.8.8.8,37.221.193.195,62.72.87.4,62.91.2.20,62.128.1.42,62.128.1.53,62.141.38.230,62.141.187.10,62.152.168.253,62.152.177.87,62.225.183.250,78.47.34.12,78.47.115.194,78.47.115.197,80.66.1.42,80.78.162.2,80.86.93.123,80.146.190.1,80.148.51.2,80.148.52.66,80.149.86.20,80.190.200.10,80.190.200.55,80.237.196.2,80.237.197.14,81.7.200.80,81.18.97.40,81.18.97.50,82.96.64.2,82.96.65.2,82.96.81.10,82.96.86.20,82.149.248.3,84.200.69.80,84.200.70.40,85.88.19.11,85.214.20.141,85.214.132.203,87.106.220.85,87.118.111.215,87.119.194.34,89.107.129.15,89.146.204.5,91.202.41.181,91.204.4.133,93.186.161.211,132.252.150.1,134.60.1.111,139.1.17.16,139.1.144.14,141.1.1.1,141.1.27.249,141.50.161.11,141.50.161.12,141.56.31.3,144.76.202.253,145.253.2.7,149.211.153.50,149.211.153.51,149.250.222.21,149.250.222.22,160.44.1.4,164.33.1.4,164.133.154.136,170.56.58.45,170.56.58.53,178.254.21.113,192.76.144.66,193.7.168.1,193.7.169.9,193.16.48.66,193.22.110.251,193.22.111.1,193.25.208.49,193.28.97.130,193.28.100.200,193.41.10.1,193.41.252.146,193.98.112.46,193.98.112.238,193.98.115.214,193.101.111.10,193.101.111.20,193.102.59.190,193.109.4.5,193.111.34.18,193.111.212.5,193.111.238.5,193.151.32.40,193.151.35.1,193.175.51.10,193.189.114.254,193.254.22.13,194.25.0.52,194.25.0.60,194.25.0.68,194.25.15.11,194.39.185.10,194.42.108.135,194.77.8.1,194.95.141.1,194.113.160.68,194.116.208.3,194.145.230.9,194.150.168.168,194.169.239.10,194.172.160.4,194.187.164.20,195.27.150.42,195.36.75.21,195.36.93.21,195.50.157.2,195.82.32.2,195.145.22.37,195.170.96.2,195.170.97.254,195.182.110.132,195.234.230.67,195.243.214.4,212.9.160.1,212.18.15.3,212.28.34.90,212.51.17.1,212.66.0.1,212.66.1.1,212.66.129.98,212.68.96.75,212.82.225.7,212.82.225.12,212.82.226.212,212.87.130.92,212.87.132.53,212.95.124.6,212.96.130.140,212.102.225.2,212.110.122.132,212.114.209.107,212.204.49.83,212.204.60.4,212.211.132.4,213.30.253.65,213.39.232.222,213.68.194.51,213.73.91.35,213.139.132.5,213.144.3.210,213.178.0.33,213.178.66.111,213.178.66.112,213.183.65.31,213.209.122.11,213.239.204.35,217.13.201.16,217.23.49.227,217.23.50.18,217.28.96.190,217.28.98.62,217.30.49.100,217.30.50.100,217.64.163.1,217.64.167.1,217.69.169.25,217.117.111.1,217.119.53.59,217.159.0.17,217.159.1.126,217.197.84.69';
my @servers = split(',', $SERVERLIST);
print @servers;
my %queryresult;
foreach my $server (@servers){
# Random DNS Query
my @chars = ("A".."Z");
my $randomhost;
$randomhost .= $chars[rand @chars] for 1..8;
print "$server, ";
my $queryresult = `dig -t any $randomhost.heise.de \@$server +time=1 +tries=1`;
my $resulttime = 0;
my @lines = split /\n/, $queryresult;
foreach my $line (@lines) {
if( $queryresult =~ /Query time: (\d+) msec/){
$resulttime = $1;
}
}
if ($resulttime > 0){
$queryresult{$resulttime} = $server;
}
}
my $time;
my $i = 1;
my $top = 10;
print "\n\n\n========================================\n";
print "Running traceroute for Top $top fastest DNS servers\n";
print "========================================\n\n";
foreach $time (sort {$a <=> $b} (keys(%queryresult))) {
if($i > $top){
last;
}
my $server = $queryresult{$time};
my $traceresult = `traceroute -w 1 -q 1 -a -m 16 $server 2>&1`;
my @lines = split /\n/, $traceresult;
my $hops = '16';
# print $lines[$#lines] . "\n";
if($lines[$#lines] =~ /(\d+)/){
$hops = $1;
}
print "#$i\t$queryresult{$time}\t\t\t$time ms query reply \t ($hops routers away)\n";
$i++;
}
@jk
Copy link

jk commented Sep 19, 2014

Did you know namebench?

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