3

We have a multi-tenant email relay set up that has a transport map file that looks like this:

domain1.com       smtp:mail.domain1.com
domain2.com       smtp:mail.domain2.com
domain3.com       smtp:mail.domain3.com
[etc]

In the event mail.domain1.com is down, email for domain1.com will be held by the postfix server until mail.domain1.com starts responding again. However we have a customer who has a backup DSL line on their site, an their email server is also available over this. How can I tell the transport to failover to a different host if the first is unavailable?

Clarification I think there is some confusion over the purpose of this setup. This postfix server is an inbound mail relay for clients who do not have AV and Spam protection on site. It is one of a pair, which are configured as the 2 MX records for these customers. They receive and clean email before forwarding it on to their local mail servers, as well as acting as a buffer in case of an outage on their end. These customers don't generally have multiple on site mail servers, they are too small hence this service. What they do often have though is a secondary connection, eg fibre and DSL, so I'd like to be able to direct the onward SMTP to their second connection should the first be unreachable.

SimonJGreen
  • 3,195
  • 5
  • 30
  • 55

2 Answers2

1

You can add a failover server declaring a new MX DNS record pointing to the failover IP (I guess the server external IP will change if it's NATed behind a DSL line).

The new MX record will have a lower weight value that the default MX record, which will prevent from using it when the default/main server is reachable

mbarthelemy
  • 378
  • 2
  • 4
  • Problem is using the smtp: transport method we send mail direct to the host, no MX lookup is performed. – SimonJGreen Nov 15 '12 at 19:58
  • Maybe I misunderstood your setup, but by default Postfix transport **will** perform a MX lookup, unless your next hop (smtp:your_host.tld) has brackets (smtp:[your_host.tld]). You can check the "EXAMPLES" section of the Postfix manual page: [http://www.postfix.org/transport.5.html](http://www.postfix.org/transport.5.html) – mbarthelemy Nov 16 '12 at 09:37
  • Backup MXen are nothing but spam attractors these days. You're assuming all clients implement the rules properly; many do not. – adaptr Nov 16 '12 at 12:59
  • I think you are missing the purpose of the setup as I wasn't clear. Please see clarification above. – SimonJGreen Nov 16 '12 at 13:21
1

The first question is WHY.

If your DNS is properly set up, relaying mail for example.com via mail.example.com is automatic; this is how it's supposed to work.

WHY are you circumventing the normal flow of email ?

If the answer is "because we cannot use DNS", then there should be no hostnames in your transport_maps at all; use bracketed IP literals:

example.com smtp:[1.2.3.4]
example.net smtp:[5.6.7.8]

As to the failover part: provided the list of relay domains is not large, you could set name resolution to "native" and put multiple IPs in the /etc/hosts file:

1.2.3.4 mail.example.com
1.2.3.5 mail.example.com
5.6.7.8 mail.example.net
5.6.7.9 mail.example.net
adaptr
  • 16,479
  • 21
  • 33