Score:0

Is it okay to have multiple A records for one MX record?

gs flag

I'm curious how mail servers behave when a hostname is balanced between two machines.

For example, when given these records:

example.com MX 10 mailer.example.com
mailer.example.com A 123.123.123.1
mailer.example.com A 123.123.123.2

When 123.123.123.1 temporarily fails to handle a mail, will the mailer retry immediately with 123.123.123.2? Or will it immediately treat it as a (temporary) failure?

RFC 974 describes the behavior of MX record fallback, where the following should work as expected, where each host is tried before failure:

example.com MX 10 mailer-1.example.com
example.com MX 10 mailer-2.example.com
mailer-1.example.com A 123.123.123.1
mailer-2.example.com A 123.123.123.2

I will probably go with this setup since it is defined to work, but I like the idea of the simpler records in the first format. Is there anything I'm missing that should make the first format well-defined behavior? Or would you say it is not recommended because mailers may treat the two A records as the "same machine" and fail fast.

Score:3
us flag

MX record fallback, as defined in RFC 974, is the standard and recommended approach for handling email delivery when one of the servers is unavailable.

According to the standard, mail servers are expected to try each host listed in the MX records in order of preference until a delivery is successful or all options have been exhausted. In the first format you mentioned (multiple A records for the same hostname), although it will work, but its not the common way.

To ensure consistent and well-defined behavior, it is recommended to use the second format (separate hostnames listed in the MX records) as described in RFC 974.

mukunda avatar
gs flag
Thanks, so the answer is no, there isn't anything I'm missing - it's up to the mailer to try different IP addresses, which honestly, doesn't make too much sense to me in an implementation (since multiple IPs might really point to the same machine, especially ipv6 vs ipv4)
Score:1
cn flag

The best way to distribute the load evenly is to use a load balancer. Without one, the distribution of load depends on the quality of the MTA's implementation of the RFCs. Even gmail seems to do both but I preferred

example.com MX 10 mailer-1.example.com
example.com MX 10 mailer-2.example.com
mailer-1.example.com A 123.123.123.1
mailer-2.example.com A 123.123.123.2
mukunda avatar
gs flag
Good answer, thanks, a load balancer is definitely a good idea if you want to take over mail server distribution yourself and block nodes that are unavailable.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.