0

We have 3 SMTP servers on 3 separate public static ip's. We have a secondary failover connection on a single static ip. I would like to put all 3 SMTP servers behind the router and off the public ip's, use postfix to accept mail on both main internet connection and failover and then route all email to the now internal SMTP servers . These are 3 different email domains. How do I set up the Postfix cnfg to achieve this? I have googled this and not found a solution that fits. I have an existing Ubuntu 16.04 box currently acting as a SSH gateway and would lkike to utilise this same machine for the smtp-gateway/ smarthost.

1 Answer 1

1

The routing of incoming email over a primary and backup internet connection is as simple as setting the correct MX priority records in DNS:

example.com.        86400   IN      MX      10 mx1.example.com.
example.com.        86400   IN      MX      20 mx2.example.com.
mx1.example.com.    86400   IN      A       <ip-on-primary-internet-connection>
mx1.example.com.    86400   IN      A       <ip-on-secondary-internet-connection>

And similar for your other domains:

example.net.        86400   IN      MX      10 mx1.example.com.
example.net.        86400   IN      MX      20 mx2.example.com.

In Postfix you need a configuration that will accept incoming mail for example.com and example.net for relaying, not for local delivery and which will route it to the correct internal server. More or less the following:

add example.com and example.net to the relay_domains paramater:

[...]
relay_domains = $mydestination, example.com, example.net
[...]

Set up a transport map, also in /etc/postfix/main.cf :

[...]
transport_maps = hash:/etc/postfix/transport
[...]

And the map /etc/postfix/transport will route the mail for each domain to a specific SMTP server:

example.com       smtp:[internalhost1.example.com]
example.net       smtp:[internalhost2.example.com]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.