Measuring DNS latency with nsping


While debugging a DNS problem a few weeks back, I needed a way to measure the time it took a name server to respond to a DNS request. After poking around the OpenBSD ports collection, I came across the nsping utility. Nsping queries a DNS server passed on the command line, and reports the time it took the server to resolve a name. The following example shows how to use nsping to measure the time it takes to resolve the name prefetch.net on the name server ns2.dreamhost.com:

$ nsping -t 5 -h prefetch.net ns2.dreamhost.com

NSPING ns2.dreamhost.com (66.201.54.66): Hostname = "prefetch.net", Type = "IN A"
+ [ 0 ] 46 bytes from 66.201.54.66: 76.224 ms [ 0.000 san-avg ]
+ [ 1 ] 46 bytes from 66.201.54.66: 79.862 ms [ 78.043 san-avg ]
+ [ 3 ] 46 bytes from 66.201.54.66: 79.902 ms [ 78.663 san-avg ]
+ [ 4 ] 46 bytes from 66.201.54.66: 79.912 ms [ 78.975 san-avg ]
+ [ 6 ] 46 bytes from 66.201.54.66: 79.920 ms [ 79.164 san-avg ]
^C
Total Sent: [ 7 ] Total Received: [ 5 ] Missed: [ 2 ] Lagged [ 0 ]
Ave/Max/Min: 79.164 / 79.920 / 76.224

Each line contains the size of the response, the time it took to complete the request, and a sequence number. The summary line contains the numer of requests that were sent to the server, the number that were missing, and the average, maximum and minimum response times. If you want to use a resource record type other than “A,” (the default resource record type) you can invoke nsping with the “-T” option the resource record type to use:

$ nsping -t 5 -h prefetch.net -T mx ns1.dreamhost.com

NSPING ns1.dreamhost.com (66.33.206.206): Hostname = "prefetch.net", Type = "IN MX"
+ [ 0 ] 136 bytes from 66.33.206.206: 73.875 ms [ 0.000 san-avg ]
+ [ 1 ] 136 bytes from 66.33.206.206: 79.905 ms [ 76.890 san-avg ]
+ [ 2 ] 136 bytes from 66.33.206.206: 80.476 ms [ 78.085 san-avg ]
+ [ 3 ] 136 bytes from 66.33.206.206: 80.030 ms [ 78.572 san-avg ]
+ [ 6 ] 136 bytes from 66.33.206.206: 80.004 ms [ 78.858 san-avg ]
^C
Total Sent: [ 7 ] Total Received: [ 5 ] Missed: [ 2 ] Lagged [ 0 ]
Ave/Max/Min: 78.858 / 80.476 / 73.875

Now to figure out why DNS responses are missing!

This article was posted by Matty on 2006-11-24 21:27:00 -0400 -0400