MX record point to itself, possible?

Lets say I have the following DNS active for domain example.com (leaving out priority and ttl)

   example.com A    123.45.67.89
mx.example.com A    123.45.67.89
   example.com MX   mx.example.com

Now, this is a valid DNS record. If I were to add the following mx record, would that cause any problems?

mx.example.com MX   mx.example.com

I have tested this, and it seems to work, but I want to be sure.

The reason is, I always used [email protected] to email without this last mx record added. But some services fail because they're not using the main domain, but rather check for the subdomain if that mx record is present. Adding the mx record seems to allwo the services to work, but I now am worried it may cause problems for actually sending/receiving email.

Also, I have set the priority for the new mx record to be lower to the original one, so in theory that should make it always choose the first one, but I'm curious it would even work if the priorities were reversed.


Solution 1:

An MX RR pointing to itself is perfectly valid and will cause no problems. It may be considered redundant, though, because of the general rule that if a domain name has no MX RR but an A RR, the latter shall be used for mail delivery. In other words, an MX RR pointing to itself is implicitly assumed when no explicit MX RR is present.

Note that your example code has syntactic problems. The FQDNs lack final dots, and the MX RRs lack priority fields. It should read:

   example.com.    A    123.45.67.89
   mx.example.com. A    123.45.67.89
   example.com.    MX   10 mx.example.com.
   mx.example.com. MX   10 mx.example.com.

or, equivalently:

   $ORIGIN example.com.
   @               A    123.45.67.89
                   MX   10 mx
   mx              A    123.45.67.89
                   MX   10 mx

(The $ORIGIN directive being redundant if the whole is part of the zone file for domain example.com.)

Solution 2:

You seemed to confuse yourself. DNS MX-RR format domain MX pref name is used to say that server with a name name will be an MX for the domain domain.

In your case you are saying that server with name mx.example.com will handle mail for mx.example.com domain. This is perfectltly valid, but it seems to me that you want to set up an MX for example.com.