Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

2 Answers 2

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

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

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.