‘dig any’ results wrong, missing data

digdns

I was playing about with 'dig' showing a friend how it worked when I spotted some odd behaviour with the 'any' type.

I believe that using 'dig any' will get all the record types automatically but that doesn't seem to be happening for some reason.

Here's my output…

; > DiG 9.4.3-P3 > ANY sourceforge.net

;; QUESTION SECTION:
;sourceforge.net.       IN  ANY

;; ANSWER SECTION:
sourceforge.net.    2390    IN  A   216.34.181.60
sourceforge.net.    3279    IN  NS  ns-1.sourceforge.com.
sourceforge.net.    3279    IN  NS  ns-1.ch3.sourceforge.com.
sourceforge.net.    3279    IN  NS  ns-2.ch3.sourceforge.com.

;; ADDITIONAL SECTION:
ns-2.ch3.sourceforge.com. 3221  IN  A   216.34.181.22

Notice how its missing the MX records? So that I ran "dig MX" and got the MX records just fine. So I decided to run 'dig any' again to check that I wasn't go mad and I got the following results…


;; QUESTION SECTION:
;sourceforge.net.       IN  ANY

;; ANSWER SECTION:
sourceforge.net.    2379    IN  A   216.34.181.60
sourceforge.net.    3268    IN  NS  ns-1.ch3.sourceforge.com.
sourceforge.net.    3268    IN  NS  ns-2.ch3.sourceforge.com.
sourceforge.net.    3268    IN  NS  ns-1.sourceforge.com.
sourceforge.net.    3597    IN  MX  10 mx.sourceforge.net.

;; ADDITIONAL SECTION:
ns-2.ch3.sourceforge.com. 3210  IN  A   216.34.181.22
mx.sourceforge.net. 1653    IN  A   216.34.181.68

And now the MX records show up!

Any idea what is going on? How do I make it actually show all the records first time?

Thanks!

Best Answer

OK, I worked out what the problem is. When I run 'any' normally it takes its results from my local cache, so it will only display the records that I have already 'seen'.

To bypass this and retrieve all the records correctly I have to direct my query to the authoritative name server for that domain.

Here's the one-liner I'm now using to do it...

dig any stackoverflow.com @`dig +short  SOA stackoverflow.com | cut -d' ' -f1`

Gives (first time)...

;; QUESTION SECTION:
;stackoverflow.com.     IN  ANY

;; ANSWER SECTION:
stackoverflow.com.  86400   IN  SOA ns1.p19.dynect.net. jatwood.stackoverflow.com. 2009090960 3600 600 604800 60
stackoverflow.com.  86400   IN  NS  ns3.p19.dynect.net.
stackoverflow.com.  86400   IN  NS  ns2.p19.dynect.net.
stackoverflow.com.  86400   IN  NS  ns4.p19.dynect.net.
stackoverflow.com.  86400   IN  NS  ns1.p19.dynect.net.
stackoverflow.com.  432000  IN  A   69.59.196.211
stackoverflow.com.  172800  IN  MX  50 aspmx3.googlemail.com.
stackoverflow.com.  172800  IN  MX  10 aspmx.l.google.com.
stackoverflow.com.  172800  IN  MX  20 alt1.aspmx.l.google.com.
stackoverflow.com.  172800  IN  MX  30 alt2.aspmx.l.google.com.
stackoverflow.com.  172800  IN  MX  40 aspmx2.googlemail.com.
stackoverflow.com.  172800  IN  TXT "v=spf1 a mx ip4:69.59.196.211 ip4:69.59.196.210 ip4:69.59.196.211 ip4:69.59.196.212 ip4:69.59.196.213 ip4:69.59.196.214 ip4:69.59.196.215 ip4:69.59.196.216 ip4:69.59.196.217 ip4:69.59.196.218 ip4:69.59.196.219 ip4:69.59.196.220 include:cmail1.com ~all"

Which is exactly the kind of output I need.

Enjoy!

Related Question