This can get quite important when your mail server is blacklisted, or if you somehow want to simply change the outgoing IP address.

First of all, check that you DO have another ip address on another interface at the server. Either by ifconfig or anything else.

To change the outgoing IP on a postfix mail server, edit the file /etc/postfix/master.cf

Find this part in the file,

smtp      unix  -       -       -       -       -       smtp
# When relaying mail as backup MX, disable fallback_relay to avoid MX loops
relay     unix  -       -       -       -       -       smtp
        -o smtp_fallback_relay=

You should modify it to look like below

smtp      unix  -       -       -       -       -       smtp
        -o smtp_bind_address=192.168.1.1
# When relaying mail as backup MX, disable fallback_relay to avoid MX loops
relay     unix  -       -       -       -       -       smtp
        -o smtp_bind_address=192.168.1.1
        -o smtp_fallback_relay=

Of course, change the IP address 192.168.1.1 to whatever your secondary IP is.

Then restart and reload the postfix server.

[root@mail ~]# /etc/init.d/postfix restart
Shutting down postfix:                                     [  OK  ]
Starting postfix:                                          [  OK  ]
[root@mail ~]# /etc/init.d/postfix reload
Reloading postfix:                                         [  OK  ]

That’s it!

Leave a Reply

Your email address will not be published. Required fields are marked *