3

I am going to redirect example.com to www.example.com. I have several records now.

example.com A 1.2.3.4
example.com NS "there are ns values"
example.com SOA "SOA value"
www.example.com CNAME mydom.example.com
mydom.example.com A 5.6.7.8

I try to change "example.com A 1.2.3.4" to cname alias record, that point to www.example.com. I get message "[RRSet of type CNAME with DNS name example.com. is not permitted as it conflicts with other records with the same DNS name in zone example.com.]"

I try to delete "example.com A 1.2.3.4" and create the new "example.com CNAME(alias) www.example.com" but I again get message "[RRSet of type CNAME with DNS name example.com. is not permitted as it conflicts with other records with the same DNS name in zone example.com.]"

How can I create cname alias record with the name that the same as zone apex?

Passatizhi
  • 46
  • 1
  • 2

2 Answers2

2

CNAME is never allowed at the apex of a zone, so that is the immediate cause of this failure, but that is somewhat unimportant, because for what you are doing, a CNAME isn't the correct record type.

If you have the record www.example.com A 203.0.113.1 and you want example.com to always return the same answer as www.example.com (currently 203.0.113.1 but you of course automatically updated if www changes in the future) then the example.com record would need to be type A with Alias = Yes and the alias target set to www.example.com.

This is exactly the same as just setting both hostnames to be normal A records and giving them the same value for IP address, except that changing one doesn't automatically change the other if you do them both manually, so having one of them as an alias for the other is usually preferrable.

The confuaion probably comes from a long-standing practice of doing something like this:

example com     A     203.0.113.1
www.example.com CNAME example.com.

This in less efficient since some lookups require twice the round trip time, so the alias approach is still preferred.

An Alias is a better solution, since it's an internal pointer to another record inside Route 53 whereas a CNAME is (in the sense relevant here) an external pointer to another record which could be anywhere. Aliases always point to the same type of record, A to A, AAAA to AAAA, CNAME to CNAME, so even if you had been allowed to create that invalid CNAME at the apex, the next problem would have been that the target of the alias wasn't a CNAME.

Michael - sqlbot
  • 22,658
  • 2
  • 63
  • 86
  • Now, we can also directly point example.com A record with alias = YES to a cloudfront distribution directly. Don't need the www.example.com CNAME record for this to work. – vighnesh153 May 15 '21 at 05:36
1

You can't have CNAME or an ALIAS to a CNAME in zone apex.

You can have ALIAS to mydom.example.com as that resolves directly to an A record.

Hope that helps :)

MLu
  • 24,849
  • 5
  • 59
  • 86
  • I guess I did not understand this document correctly. https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/resource-record-sets-choosing-alias-non-alias.html – Passatizhi Jan 11 '20 at 07:41
  • 1
    Alias brings the referenced record forward. Ie if you make `example.com` an ALIAS for `mydom.example.com` and then you do `host exsmple.com` you’ll see it’s an A record `5.6.7.8`. No sign of `mydom` in the response, unlike with CNAME where you can see `mydom` as an intermediate record. – MLu Jan 11 '20 at 08:49
  • The documentation from the link above says _"You can't create a CNAME record for example.com, but you can create an alias record for example.com that routes traffic to www.example.com"_ which is a bit misleading. As mentioned by @Mlu this doesn't work if _www.example.com_ is itself is a CNAME. You'll get the following error when trying to create the ALIAS(CNAME) _"(InvalidChangeBatch 400: RRSet of type CNAME with DNS name xxx is not permitted as it conflicts with other records with the same DNS name in zone xxx"_. – catanman Jan 22 '21 at 20:12