Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Let's say we have a subdomain called which has a CNAME record pointing at in turn has an A record pointing at the IP address

Now, if I do a DNS lookup of I'll get an answer looking like this: IN CNAME IN A

My question is, at what stage is resolved? Is it done by the recursive DNS server before the response is sent back to the client? Or does the client issue a second request to the DNS server, this time for Or does it depend on whether the DNS server already has a cached entry for

I'm asking because one particular recursive DNS server returns only the first line, ie it does not resolve the CNAME. However, after perhaps 20 seconds, subsequent requests for the same host will then include both lines.

share|improve this question

1 Answer 1

up vote 11 down vote accepted

The 2 records are returned together in the same request. You can find that out via the following command

dig +trace

For example my domain has a cname for www so the last 2 requests from photoblog's name server to me look like      172800  IN  NS      172800  IN  NS
;; Received 103 bytes from in 196 ms  600 IN  CNAME      600 IN  A      60  IN  NS      60  IN  NS
;; Received 133 bytes from in 59 ms

As you can see the request asks ns1/ns2 what is the ip for and it returns well it's a cname to and here is the ip for that A record.

share|improve this answer
In the OPs your example where it gave just the CNAME back, the DNS server likely had difficulty following the CNAME and so gave the client whatever information it had. Eventually, it finished following the CNAME and so was able to give a complete reply. –  David Schwartz Aug 21 '12 at 14:10
Yeah - if the DNS server has more information, then it will return it in the ADDITIONAL section of the answer. The occasions where it doesn't return it mean that the recurser didn't have it in its cache - potentially because the CNAME and the A record it points to have different authoritative servers (so the recurser's initial request didn't get the CNAME plus additional A response, just the CNAME). –  Shane Madden Aug 22 '12 at 4:10
@Mike: so what's the conclusion? Does the CNAME records result in a second DNS lookup or not? If not, why many suggests to increase CNAME record TTL? –  Marco Demaio Feb 22 '13 at 13:32
as long as the A record is in the same authoritative server as the CNAME it's the same lookup –  Mike Feb 22 '13 at 19:06

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.