30

I have set up DNS for my website so that example.com is an A record (pointing to the IP), but I don't know what to do about www.example.com.

I intend to add a CNAME record www.example.com so it would become an alias of example.com.

BUT, I've been checking my settings with https://intodns.com and it shows:

ERROR: I could not get any A records for www.example.com!

The error clears if I change www to A record. Is there a "rule" requiring that?

kubanczyk
  • 13,502
  • 5
  • 40
  • 55
Sorin Buturugeanu
  • 311
  • 1
  • 3
  • 4

2 Answers2

19

The difference between having an A record vs CNAME for www would be an extra look up. In case of the CNAME the after figuring out that www is a CNAME to example.com, another look will be done for example.com.

Other than that if you are planning to use a CDN or a 3 party acceleration service then a CNAME would come into play. Example a lookup of www.google.com results in the following. Notice the difference in TTL of www.l.google.com and www.google.com

www.google.com.     36545   IN  CNAME   www.l.google.com.
www.l.google.com.   294     IN  A       209.85.153.104

This gives the flexibility of changing the record, keeping a lower TTL, doing fancy stuff like geo redirection, if employing third party services.

In your case it doesn't matter since you are pointing both to the same IP.

Andrew Schulman
  • 8,561
  • 21
  • 31
  • 47
Sameer
  • 4,070
  • 2
  • 16
  • 11
4

There is no rule that the www. address needs to be an A record. It is very common for a web site to be a CNAME to something else. For example:

$ host www.google.com
www.google.com is an alias for www.l.google.com.

Or:

$ host www.kodak.com
www.kodak.com is an alias for www.Kodak.com.edgekey.net.

If things aren't working for you, it suggests a configuration error. Without seeing your actual DNS records it's hard to help out, but using command line tools like dig can help you debug the problem by showing you exactly what DNS records are being exposed by your name servers.

larsks
  • 41,276
  • 13
  • 117
  • 170
  • 2
    The actual domain is cexa.ro. I've had the CNAME deleted for the nigh and I've just re-added it. CNAME www.cexa.ro. alias for cexa.ro. From your answer and from Sameer's I understand that if the resulting IP is the same it makes no difference (I'm not concerned by the extra lookup). Thanks! – Sorin Buturugeanu Jan 18 '11 at 06:38