3

My hosting company has set up the DNS records for my site so that there are two entries for www:

example.com       A       192.0.2.222
www.example.com   A       192.0.2.222
www.example.com   CNAME   example.com

Is there a reason for having both an A record and a CNAME record for www?

I now wish to redirect www to a completely different site.

I'm guessing that I have to delete the A record for www and change the CNAME record for www to refer to the URL of the other site. Is that correct?

Patrick Mevzek
  • 10,581
  • 7
  • 35
  • 45
JavaLatte
  • 133

2 Answers2

9

No, there is not. This is actually considered as an error, explained below.

In this case, where you want to redirect www to a completely different site, you'd remove both the CNAME and the A and replace it with another record of either the type A or CNAME, but not both.

Also notice that CNAME works merely as an alias for the canonical name. It won't perform any actual redirection, as redirection is a function of the HTTP protocol, instead of DNS.


If a hostname has a CNAME record, it must not have other resource records of other type. References:

RFC 1912, 2.4 CNAME records

A CNAME record is not allowed to coexist with any other data. In other words, if suzy.podunk.xx is an alias for sue.podunk.xx, you can't also have an MX record for suzy.podunk.edu, or an A record, or even a TXT record. Especially do not try to combine CNAMEs and NS records

If you use a CNAME, the DNS server should return both CNAME record and the A record for the canonical hostname it's pointing to. The same applies to IPv6 AAAA records.

RFC 1034, 3.6.2 Aliases and canonical names

For example, suppose a name server was processing a query with for USC-ISIC.ARPA, asking for type A information, and had the following resource records:

USC-ISIC.ARPA   IN      CNAME   C.ISI.EDU

C.ISI.EDU IN A 10.0.0.52

Both of these RRs would be returned in the response to the type A query, while a type CNAME or * query should return just the CNAME.

The only exception is DNSSEC.

RFC 2181, 10.1 allowed SIG, NXT, and KEY records, while the currently used definition is:

RFC 4035, 2.5 Changes to the CNAME Resource Record

If a CNAME RRset is present at a name in a signed zone, appropriate RRSIG and NSEC RRsets are REQUIRED at that name. A KEY RRset at that name for secure dynamic update purposes is also allowed ([RFC3007]). Other types MUST NOT be present at that name.

This is a modification to the original CNAME definition given in [RFC1034]. The original definition of the CNAME RR did not allow any other types to coexist with a CNAME record, but a signed zone requires NSEC and RRSIG RRs for every authoritative name. To resolve this conflict, this specification modifies the definition of the CNAME resource record to allow it to coexist with NSEC and RRSIG RRs.

Esa Jokinen
  • 52,963
  • 3
  • 95
  • 151
2

It is a mistake to have both records. You can safely remove A record and edit CNAME to point to another site.

MTG
  • 203