Configuring Multiple Mail Servers in DNS

4.3.1 Problem

You want to configure DNS so that mail addressed to a destination will be sent to one of a number of equivalent mail servers.

4.3.2 Solution

Add MX records for the domain name of the mail destination, pointing to the domain names of the mail servers, all at the same -- and lowest -- preference value. For example:

foo.example. IN MX 10 smtp1.foo.example. foo.example. IN MX 10 smtp2.foo.example. foo.example. IN MX 10 smtp3.foo.example.

4.3.3 Discussion

Most modern mail servers that have mail to send to a destination will choose randomly among mail servers with the same preference value. All of these mail servers are the "final destination" for the mail, as far as DNS is concerned, so all should be configured to see the mail destination as local.

If one of the mail servers fails, a mail server trying to send mail to the destination will simply try another of the mail servers.

Using multiple "main" mail servers doesn't preclude your listing one or more backup mail servers, too. Just add MX records pointing to the destination's backup mail servers, with higher preference values than the value you used for the main mail servers. For example:

foo.example. IN MX 10 smtp1.foo.example. foo.example. IN MX 10 smtp2.foo.example. foo.example. IN MX 10 smtp3.foo.example. foo.example. IN MX 20 backup.isp.net.

Mail servers sending mail to the destination will only try the backup mail server if they fail to deliver the mail to all more-preferred mail servers.

4.3.4 See Also

Section 2.5 for instructions on setting up a mail destination and Section 4.2 for designating backup mail servers for a destination, as well as "MX Records" in Chapter 5 of DNS and BIND.

Категории