This has been going on for two days now and it's really bugging me.

I've owned a domain name for a few years now. Let's call it example.com. I've had Google Apps free edition set up there for a few years and all is good. example.com has an A record pointing at a VPS that I own and MX records pointing at Google. I also have all email from example.com forwarded to my personal gmail account.

Just recently I registered a domain name for my friend's business that he is starting and set him up with Google Apps free edition. Let's called it example.net. This domain has MX records pointing at Google and a CNAME pointing at example.com -- I am using virtual hosts on my VPS to determine which page to serve -- basic stuff.

Here's the problem. All email sent to example.net ends up at example.com. Would the CNAME cause this? And why would it? I didn't think that CNAME records affect email. There are no filters set up for any email at example.net.

In the email headers I see To: friend@example.net. Moving up the header I see this out of nowhere:

X-Forwarded-To: personal@gmail.com
X-Forwarded-For: me@example.com personal@gmail.com

The only explanation I can think of is the CNAME record pointing from example.net to example.com. Can anybody verify this for me or possibly name another reason for this to happen?

  • If only there were a domain name specifically reserved for examples... Oh, wait. – Joel Coel Dec 8 '11 at 23:08
  • As for X-Forwarded, probably it's normal because it google forwards it from your apps to your private gmail. Guess you see it in all messages to example.com. – Sandman4 Dec 9 '11 at 1:01

Yes, a CNAME record on domain2.com takes precedence over any other record on domain2.com.

According to the RFC, no other type of resource record (be it A, MX, or otherwise, except for DNSSEC supporting types SIG, NXT, and KEY) can exist on the same name as a CNAME; a BIND name server won't even load a zone with that kind of conflict present.

  • Well then, I learned something today. I'll just have to update the DNS records (and accept your answer in 9 minutes when ServerFault lets me). – knpwrs Dec 8 '11 at 23:10
  • @KPthunder Can we edit "incorrectly" to "correctly" in your question now? :-) – ceejayoz Dec 8 '11 at 23:15
  • @ceejayoz I changed it to "unexpectedly." Is that good enough? :P – knpwrs Dec 8 '11 at 23:18
  • 1
    @Sandman4 I removed the CNAME and changed it to an A record of the same IP address of my VPS and now everything works unlike the last two days. – knpwrs Dec 9 '11 at 3:41
  • 1
    @sandman4: it happens because when a CNAME is encountered the sending SMTP server is at liberty to rewrite the recipient address to the target of the CNAME (i.e. example.net CNAME example.com; user@example.net is rewriteable to user@example.com.) Then example.com happily accepts the mail. But you should never use CNAME at the top-level of a zone anyway: It's not valid (as highlighted above). Use the same IP address if you were doing it for a web server, etc., and manage any future changes. – jrg Mar 22 '13 at 14:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.