Local DNS server access delays Access to a local DNS server is always delayed by ~1 second.

I enabled the DNS server on OS-X Lion and it does indeed work.  However when I query it using 'dig' (or nslookup) there is a delay of about 1 second before the reply is given. This delay is not reported by 'dig', which gives a response time of 0ms. 

So for example a query using the OpenDNS servers completes sooner than one to the local server despite the name resolution taking 135ms longer:

$ time dig @208.67.220.220 ibm.com

;; Query time: 135 msec

real    0m0.172s
user    0m0.008s
sys 0m0.006s

$ time dig @localhost ibm.com

;; Query time: 0 msec

real    0m1.068s
user    0m0.009s
sys 0m0.007s

The delay does not seem to be in the named server, as when using named -g to view logs there is also a 1s delay before the request is printed. 

FYI: my changes to enable DNS were:

rndc-confgen -b 256 > /etc/rndc.conf
head -n5 /etc/rndc.conf | tail -n4 > /etc/rndc.key
edit /etc/rndc.conf to correct port number
edit  /etc/named.conf to add this to the options:

forward first;
forwarders {
    208.67.222.222;
    208.67.220.220;
};


run named from the shell (/usr/sbin/named -g)
If you have 127.0.0.1 localhost in /etc/hosts you also need to add a ::1 localhost line.

You may find that the delay has something to do with resolving the name 'localhost'. If you use 127.0.0.1 instead, the delay should be reduced to milliseconds.

$ time dig @127.0.0.1  muc.de

;; Query time: 10 msec

real 0m0.029s
user 0m0.007s
sys 0m0.005s

I don't know where the resolution of 'localhost' occurs or why it takes such a long time, but I guess it doesn't really matter...