Not to lose mails when main mail server is down, best solution is – mx backup server.
This is configuration to have backup mx server set up and running.
1 2 3 4 5 6 7 8 9 10 11 |
myhostname = mx2.loginroot.com mynetworks = 127.0.0.0/8 maximal_queue_lifetime = 120d smtpd_banner = $myhostname ESMTP relay_domains = hash:/etc/postfix/relaydomains transport_maps = hash:/etc/postfix/transportmaps smtpd_recipient_restrictions = permit_mynetworks, reject_unauth_destination |
create /etc/postfix/relaydomains with contents:
1 2 |
loginroot.com OK otherdomain.tld OK |
then to create map for postfix – run:
1 |
postmap /etc/postfix/relaydomains |
create /etc/postfix/transportmaps with contents:
1 2 |
loginroot.com smtp:mx1.loginroot.com:25 otherdomain.tld smtp:primary_mx_server:port |
and run:
1 |
postmap /etc/postfix/transportmaps |
Backup MX should be added in DNS zone in order to receive mails.
In my case I have such records:
1 2 3 4 |
% dig mx loginroot.com +short 10 mx1.loginroot.com. 20 mx2.loginroot.com. |
First digit means priority. The bigger value, the smaller priority.
So my MX backup server is mx2. It receives mail only if higher priority server is down.
That’s it.