Let's say we have a subdomain called www.foo.com which has a CNAME record pointing at foo.bar.cc. Foo.bar.cc in turn has an A record pointing at the IP address

Now, if I do a DNS lookup of www.foo.com I'll get an answer looking like this:

www.foo.com. IN CNAME foo.bar.cc.
foo.bar.cc. IN A

My question is, at what stage is foo.bar.cc 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 foo.bar.cc? Or does it depend on whether the DNS server already has a cached entry for foo.bar.cc?

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.

1 Answer 1


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

dig +trace www.foo.com

For example my domain photoblog.com has a cname for www so the last 2 requests from photoblog's name server to me look like

photoblog.com.      172800  IN  NS  ns1.photoblog.com.
photoblog.com.      172800  IN  NS  ns2.photoblog.com.
;; Received 103 bytes from in 196 ms

www.photoblog.com.  600 IN  CNAME   photoblog.com.
photoblog.com.      600 IN  A
photoblog.com.      60  IN  NS  ns2.photoblog.com.
photoblog.com.      60  IN  NS  ns1.photoblog.com.
;; Received 133 bytes from in 59 ms

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

  • 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. Aug 21, 2012 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). Aug 22, 2012 at 4:10
  • 1
    @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? Feb 22, 2013 at 13:32
  • 12
    as long as the A record is in the same authoritative server as the CNAME it's the same lookup
    – Mike
    Feb 22, 2013 at 19:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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