On Monday, 4 August 2003, at 07:46AM, Stephane Bortzmeyer wrote:
I'm looking for a small tool (running on Unix) that can take a list of DNS servers, a query to ask (such as "A ns1.nic.fr.") and which can print the fastest server to reply.
Something like "netselect" which only exercices the kernel, not the actual servers, unfortunately (and which can be blocked by filters):
~ % netselect {a,b,c,d,e,f,g,h,i,j,k,l,m}.root-servers.net 123 i.root-servers.net
BIND9's lib/dns/resolver.c has code to do so and I wonder if someone extracted it in a simple tool?
#!/bin/sh # q=$1; shift # [ -z "$*" ] && echo "Syntax: $0 query server..." && exit 1 # for m in 0 1 2 3; do for n in $*; do dig @${n} ${q}; done done | \ awk '/^;; Query time:/ { qt = $4; } \ /^;; SERVER: / { sum[$3] += qt; n[$3]++; } \ END { for (s in sum) { print int(sum[s]/n[s]), s; } }' | \ sort -n | head -1 [jabley@snowfall]% ./qtest.sh ". NS" a.root-servers.net b.root-servers.net c.root-servers.net d.root-servers.net e.root-servers.net f.root-servers.net g.root-servers.net h.root-servers.net i.root-servers.net j.root-servers.net k.root-servers.net l.root-servers.net m.root-servers.net 40 192.58.128.30#53(j.root-servers.net) [jabley@snowfall]%