Home
| Calendar
| Mail Lists
| List Archives
| Desktop SIG
| Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings Linux Cafe | Meeting Notes | Linux Links | Bling | About BLU |
On 20 Oct 2004 dsr at tao.merseine.nu wrote: > Virtually every nameserver will have authoritative records for > "localhost" (although they may be "NXDOMAIN"). That should be a > minimal 1 packet request, 1 packet response, no waiting. I was thinking about what domain to use for the test and had decided to try localhost. At first I thought of the nameserver's domain, but then realized the server can't be authoritative for its own domain or there's a loop (is this allowed?) -- though it would probably have its own domain in its cache. Played around with dig a bit -- a query like this: dig @server localhost +time=1 seems to do what I want. Returns an exit code of 9 if it can't reach the server, 0 if it can, which means I can ignore the output itself. The time option seems to determine half the actual elapsed time, for example: $ time dig @blu.org localhost +time=2 ; <<>> DiG 9.2.1 <<>> @www.microsoft.com localhost +time=2 ;; global options: printcmd ;; connection timed out; no servers could be reached real 0m4.030s user 0m0.000s sys 0m0.020s +time=1 seems to do what I want, on the server on which the code will run. For Bob G, the PHP functions (checkdnsrr() or, in PHP 5, dns_get_record()) won't work for this purpose as they do not allow you to specify the server, only the host to look up. As a result I'd have to use the socket functions, so just invoking dig may be the best solution. -- Tom
BLU is a member of BostonUserGroups | |
We also thank MIT for the use of their facilities. |