I recently moved a bunch of websites over to a VPS (likely the one you are reading this from). It runs Ubuntu with a LEMP stack.
I ran into some problems when I went to reconfigure my DNS Zones to reflect the change. The zones (combined) I created looked more-or-less like this:
NAME TYPE VALUE -------------------------------------------------- mydomain.com. CNAME vps.mydomain.com sub.mydomain.com. CNAME vps.mydomain.com othersite.com. CNAME vps.mydomain.com vps.mydomain.com. A 1.2.3.4 (my VPS's IP) @ MX ASPMX.L.GOOGLE.COM (plus the other MX records)
…
There’s a lot of records pointing to vps.mydomain.com, and only one ‘A’ record for vps.mydomain.com that points to my VPS’s actual IPv4 address.
This way I just have to update the one record if my VPS’ IP address changes. Makes sense, doesn’t it?
I thought so, but could not make this configuration work. After some research, I learned that according to RFC 1912 s.2.4, a ‘TLD cannot be a CNAME’. When I adjusted the zone as below, it all worked again.
NAME TYPE VALUE -------------------------------------------------- mydomain.com. A 1.2.3.4 (VPS’s IP) sub.mydomain.com. CNAME mydomain.com othersite.com A 1.2.3.4 vps.mydomain.com. A 1.2.3.4 @ MX ASPMX.L.GOOGLE.COM (plus the other MX records)
What’s frustrating is that both strategies actually seem to work when the NS records point to a cPanel server hosting the zone file, but do not when the zone is served directly by my registrar’s “free DNS hosting”. This led to an argument with my registrar/host where I declared that their DNS server was broken (when it was actually just following RFC strictly), and they maintained that there was “no way to have an A and an MX record in the same zone, which wasn’t right either. In the end, we were both wrong!
Leave a Reply