multiple MX pointing to the same server

I need help for a mail server configuration.
I would like to know if it’s possible to have multiple MX with different pub IP, pointing to the same local server.
this is because in my environment exist 2 gateway (multiple services providers), a watchguard t30 (local 10.0.0.254) that manage 12.12.12.5 and a watchguard t35 (local 10.0.0.253) that manage 12.12.12.6, for failover purpose. they share the same isp router has the 12.12.12.0/28.

watchguard t35 – loc 10.0.0.254 – pub 12.12.12.5

watchguard t30 – loc 10.0.0.253 – pub 12.12.12.6

zone mycompany.com:

mycompany.com. MX 5 mail.mycompany.com
mycompany.com. MX 15 samemail.mycompany.com
mycompany.com. TXT "v=sfp1 a mx ip4:12.12.12.5 ip4:12.12.12.6 ~all"
mail.mycompany.com. A 12.12.12.5
samemail.mycompany.com A 12.12.12.6

zone 12.12.12.in-addr.apra:

5.12.12.12.in-addr.arpa. PTR mail.mycompany.com.
6.12.12.12.in-addr.arpa. PTR samemail.mycompany.com.

on firewall1: nat 12.12.12.5 – 10.0.0.1 commons mail ports

on firewall2: nat 12.12.12.6 – 10.0.0.1 commons mail ports

MAILSERVER nic config

ip: 10.0.0.1
subnet mask: 255.0.0.0
gw 10.0.0.254 metric 2
gw 10.0.0.253 metric 50 

In this way when the first gateway goes down, all the request start comes (and goes out) from 10.0.0.253 (12.12.12.6) on common ports (25..443..) instead of the gateway with metric 2.

or maybe I could assign another NIC to the mail server and change all rules on firewalls, and then works with INTERFACE metrics, like in the example:

MAILSERVER NIC1

10.0.0.1 
255.0.0.0
10.0.0.254
nic metric 2

NIC2

10.0.0.2
255.0.0.0
10.0.0.253 
nic metric 50  

I would like to know if there is any contraindication in using this method, or if there are alternatives..
other infos, the mailserver is Mdaemon.
every help is appreciable!

edit:
If I use the configuration with two gateways and different metrics, my server will always use the one with the lowest metric 10.0.0.254 (12.12.12.5) until it finds it online. Unless I set some particular route, the server will not be able to use the secondary 10.0.0.253 (12.12.12.6), not even port 25 and the other common ports will listen. I did a test, I launched a continuous query on port 25 on 12.12.12.5 and on 12.12.12.6, in the meantime of this test I turned off the firewall 10.0.0.254 (12.12.12.5), the server has therefore stopped listening on it, and began to listen on the secondary firewall in metric. are there scenarios where my server could start communication not using the 10.0.0.254 when it is online?
test fw1 down

Answer

Hi this configuration will not do what you suppose it would to do :-(. Mainly the DNS records would be for the domain (the most probably you have this correct but for the readers to have it visible correctly)…

zone mycompany.com:

mycompany.com. MX 5 mail.mycompany.com
mycompany.com. MX 15 samemail.mycompany.com
mycompany.com. TXT "v=sfp1 a mx ip4:12.12.12.5 ip4:12.12.12.6 ~all"
mail.mycompany.com. A 12.12.12.5
samemail.mycompany.com A 12.12.12.6

zone 12.12.12.in-addr.apra:

5.12.12.12.in-addr.arpa. PTR mail.mycompany.com.
6.12.12.12.in-addr.arpa. PTR samemail.mycompany.com.

From the DNS point of view it is correct but the issue may be the routing on server side. Based on the network setting you have post, it is not behave internally as two independent network connection on server side but all the time it is preferred to use 10.0.0.254 / 12.12.12.5 even in case the communication has been started using 10.0.0.253 / 12.12.12.6 (for any reason). In some cases it may work but in other cases it will not work (like in case other side has utilized e.g. Cisco ASA – at that moment it will not be recognized as related communication and it will be terminated).

To have it working it would be better to utilize some HA options on gateway side and – e.g. Virtual IP, Stand-by gateway,… And on dns side to use one MX record. As it is “ending” on the same router of ISP it would not be an issue. The mail server would have at that moment also just one interface.

In case you would insist on two interfaces on mail server it may be possible but you need to make sure that the response will follow the same gateway which would be used to established the connection. The easiest way would be sNAT on gateway / firewall but in case of mail server it is not good idea as you are loosing the track of source IP (e.g. spam check based on source IP) so some other (more complicated approach would be selected).

Attribution
Source : Link , Question Author : bind2lrz , Answer Author : Kamil J

Leave a Comment