DNS using CNAMEs breaks MX records?
Solution 1
This is a common error. You cannot use a CNAME RR for your root domain (e.g. company.com) and define additional resource records for the same zone.
See Why can't I create a CNAME record for the root record? and RFC1034 section 3.6.2 for details:
If a CNAME RR is present at a node, no other data should be present; this ensures that the data for a canonical name and its aliases cannot be different.
Solution 2
RFC2181 section 10.3 says you can't point your MX record to a CNAME:
The domain name used as the value ... of a MX resource record must not be an alias.
Solution 3
I just moved to Heroku which uses CNAMEs instead of A records and what I had to do was instead of making a CNAME with my_domain.com pointing to heroku, I did the CNAME with www.my_domain.com pointing to heroku, so the bare/root domain was not forwarding and my MX records would still work. Then I added a pointer to redirect my_domain.com to www.my_domain.com. It seems to work great. In my domain name provider the pointer was created using a 'pointers' setting which I set to 'standard' 'URL' and 'www.my_domain.com'
Related videos on Youtube
johnwards
Updated on September 17, 2022Comments
-
johnwards over 1 year
We are trying to move all our websites we host to CNAMES as we are planning on moving servers in the new year and would like the ability to move some clients to one server and other clients somewhere else. We were planning on giving clients a unique CNAME which we can then change at a later date. (We have other reasons for doing this now but that is the main one)
We have been testing out this theory with a few of our own domains and it seemed to be fine. However when checking the MX records on a domain I got the CNAME value back rather than the MX record.
Sadly all of these domains are done via control panels, but I am guessing they are just writing zone files for me.
I want to create 2 CNAMEs for the company.com
company.com. IN CNAME client.dns.ourserver.com www IN CNAME client.dns.ourserver.com
The MX record is something like the following:
company.com IN MX 10 mail.company.com
We have an A record for mail.company.com
Doing:
host -t mx company.com
Returns the CNAME value rather than the mx record.
Is this expected behaviour?
I have managed to get the above configuration working with the 123-reg.co.uk control panel, but not sure if that is more luck than anything.
-
Admin over 14 yearsThis is a common question and has been asked many times before. See this link for an example: serverfault.com/questions/18000/…
-
Admin over 14 yearsI did spend a little while looking for an answer but couldn't figure out if I was doing something different. Especially as it is working fine with one domain provider. I have my answer so that is cool and hopefully it will be of some use to someone.
-
-
Doktor J over 10 yearsThe problem is, as per RFC1034, "if a CNAME RR is present at a node, no other data should be present" -- since the root needs to have NS records (to be useful, anyways), there will always be other data, which violates this section of the RFC.
-
Håkan Lindqvist about 9 yearsRFC2181 Section 10.1 is also relevant in that in reinforces the above.
-
Håkan Lindqvist about 9 yearsThat isn't really the scenario that the question is about, though?
-
Alexander Taubenkorb over 8 yearsIn my opinion the answer is correct, except that the MX record should be instead on the CNAME host (not also).
-
ceejayoz almost 8 yearsBeing undocumented behavior, this is definitely not something I'd want to count on.
-
Alex78191 almost 7 yearsalso known as apex domain
-
Jasen almost 6 yearsthis behaviour can only be considered a bug, a caching nameserver may cache the CNAME response ans MDAs will never see the MX record tools.ietf.org/html/rfc5321#section-5.1
-
duhaime over 4 yearsSolid work! Thanks for sharing this!
-
Utsav T almost 4 yearsHi @Jesse Adamson, where did you add a pointer to redirect my_domain.com to www.my_domain.com ?
-
Jesse Adamson almost 4 years@Utsav T, log into your domain name provider account and look for some kinda option to add a redirect or forward or something like that.