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!

About The Author

Comments

  1. Fred

    When using Postfix on multiple ip’s for receiving mail it can be good to fix the outgoing ip. Some remote mailservers will deny incomming mail when there is no correct reverse dns set. So it can be necesarry to fix the outgoing ip to the one with the correct reverse dns.

    But how can this be done for ipv6?

    Does
    smtp inet n – n – – smtpd
    -o smtp_bind_address=xxx.xxx.xxx.xxx
    -o smtp_bind_address6=xxxx:xxxx:xxxx::xxxx

    work?