Take the 2-minute tour ×

Here's how I have my DNS records setup:

domain.com          IN     A         <server ip>
sub1.domain.com     IN     CNAME     domain.com
sub2.domain.com     IN     CNAME     domain.com
www.domain.com      IN     CNAME     domain.com

sub1.domain.com and sub2.domain.com are alternate ways of accessing domain.com. By default my host had an A record for *.domain.com but I removed it.

Is this setup correct?

share|improve this question
Is this configuration related to bind or a dns provider web interface (or any other software) ? If this is a zone file in bind, you have some misconfiguration. The records should be: "sub1 IN CNAME domain.com.". Notice the lack of ".domain.com" in sub1 and the addition of "." in domain.com. –  Torian Sep 30 '10 at 16:48
This is my configuration in my host's control panel interface. –  AmIDoingThisRight Sep 30 '10 at 17:21
add comment

2 Answers

The A record for domain.com is exactly right, you can't use a CNAME there.

My personal view is that pointing a CNAME back at the apex of your domain is sub-optimal:

  1. It inadvertently means that any other records at your apex (especially NS, SOA and MX) also exist for those subdomains. That may have unintended consequences.
  2. It's marginally slower than using an A record as the DNS client has to follow the CNAME chain.

To avoid the first problem my recommendation would be:

domain.com          IN     A         <server ip>
www.domain.com      IN     A         <server ip>
sub1.domain.com     IN     CNAME     www.domain.com
sub2.domain.com     IN     CNAME     www.domain.com
share|improve this answer
add comment

Alternatively, you don't even need CNAME records, and I don't recommend using them unless you have a really good reason to do so.

domain.com          IN     A         <server ip>
www.domain.com      IN     A         <server ip>
sub1.domain.com     IN     A         <server ip>
sub2.domain.com     IN     A         <server ip>
share|improve this answer
Why do you not recommend using CNAMES? –  dunxd Sep 30 '10 at 17:15
They are faster (1 query vs 2 queries). It is especially useless when you are just looking at the same server, CNAMEs are best for pointing to a server outside your domain, see this article: rscott.org/dns/cname.html –  MaQleod Sep 30 '10 at 17:54
After reading that CNAMEs are a bit slower, like you mentioned, I deleted my CNAMEs and replaced them with As. Now I can't access www.domain.com but can access domain.com. What should I do? OpenDNS's cache checker is returning NXDOMAIN for www. by the way –  AmIDoingThisRight Sep 30 '10 at 18:40
It may take some time for the changes to propagate. Some hosts can take 24-48 hours, some will have it updated in 4-6 hours. –  MaQleod Sep 30 '10 at 22:54
add comment

Your Answer


