Skip to content

Instantly share code, notes, and snippets.

@fairchild
Created March 6, 2009 18:23
Show Gist options
  • Select an option

  • Save fairchild/75007 to your computer and use it in GitHub Desktop.

Select an option

Save fairchild/75007 to your computer and use it in GitHub Desktop.
DNS ping timer
#simple script to check the ping times of various DNS servers
results = Hash.new
dns_servers = %w(4.2.2.1
4.2.2.2
4.2.2.3
4.2.2.4
4.2.2.5
4.2.2.6
68.94.156.1
68.94.157.1
204.117.214.10
199.2.252.10
204.97.212.10
208.67.222.222
208.67.220.220
216.234.234.30
12.96.160.115
216.39.90.2
216.39.90.3
72.36.190.2
72.36.191.2
66.215.64.14
24.205.1.14
192.168.4.1
)
command = "ping -c 3"
puts "#{command}\n"
printf "%-16s %-6s\n", "Server", "Average Latency"
puts "--------------------------------------"
dns_servers.each do |d|
output = `#{command} #{d}`
results[d.to_s] = output.split("\/")[-3].to_f
printf "%-16s %.2f\n", d, results[d.to_s]
end
puts "\n--- Sorted Results ---"
results.sort{|a,b| a[1]<=>b[1]}.each { |elem|
printf "%-16s %.2f\n", elem[0], elem[1]
}
# Commented DNS server list:
# 4.2.2.1
# 4.2.2.2
# 4.2.2.3
# 4.2.2.4
# 4.2.2.5
# 4.2.2.6
# These are all DNS server addresses that resolve differently across the country. Some are GTE, some Level3, some Verizon, but are all VERY speedy and work well. Some also reccomend using the ORSC’s public servers, one of which is 199.166.24.253. I have not used this server, but others say it is fast.
#
# SpeakEasy Nameservers
# 66.93.87.2
# 216.231.41.2
# 216.254.95.2
# 64.81.45.2
# 64.81.111.2
# 64.81.127.2
# 64.81.79.2
# 64.81.159.2
# 66.92.64.2
# 66.92.224.2
# 66.92.159.2
# 64.81.79.2
# 64.81.159.2
# 64.81.127.2
# 64.81.45.2
# 216.27.175.2
# 66.92.159.2
# 66.93.87.2
#
# ORSC Public Access DNS Nameservers
# 199.166.24.253
# 199.166.27.253
# 199.166.28.10
# 199.166.29.3
# 199.166.31.3
# 195.117.6.25
# 204.57.55.100
#
# Sprintlink General DNS
# 204.117.214.10
# 199.2.252.10
# 204.97.212.10
#
# Cisco
# 128.107.241.185
# 192.135.250.69
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment