How to use same CNAME label for MX
You don't. You use ALIAS and MX for single root domain.
f you try to set CNAME on the same DNS label already used by another label besides A or AAAA:
example.com. 3600 IN MX 10 in1-smtp.email.
example.com. 3600 IN MX 20 in2-smtp.email.
example.com. 3600 IN CNAME some.random.other.site.You will get an error! This is because you cannot set CNAME with any other record type on a label, as described by RFC-1034.
But if you change to say the third DNS label instead of second:
example.com. 3600 IN MX 10 in1-smtp.email.
example.com. 3600 IN MX 20 in2-smtp.email.
a.example.com. 3600 IN CNAME some.random.other.site.You get working CNAME, because no conflict.
What if you want to use the same label as the CNAME? Not a different label. Normally this is a no go. But if you have access to the ALIAS record type, like with the excellent @dnsimple.com, you can.
Simply put, using the non standard RFC record type, you can set to the same label and as such have access to out both CNAME and MX records.
You swap the label CNAME to ALIAS record and you good to go!
a.example.com. 3600 IN MX 10 in1-smtp.email.
a.example.com. 3600 IN MX 20 in2-smtp.email.
a.example.com. 3600 IN ALIAS some.random.other.site.The way it works is due to how ALIAS points by being something like a dynamic A record. So for locations you want a CNAME and an MX or other record type, use ALIAS. When your DNS provider has it that is.
Anyway, don't be like me. Don't cause an email outage forgetting this simple rule! Use ALIAS:
Did you enjoy this article?
Recommend it — Standard Reader surfaces well-loved writing to more readers across the network.