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 1.2.3.4.
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 1.2.3.4
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.
The 2 records are returned together in the same request. You can find that out via the following command
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
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.