I'm using the Postfix mail server and I have 6 IPs available. I'd like to use another IP for the Postfix mail server for sending mail than the web server uses.

How can I do this? My postfix version is 2.3.3.

For example: main IP: other IP:

5 Answers 5


You want smtp_bind_address= and inet_interfaces=all or inet_interfaces=eth(whatever) that is on.

Make that change, then stop/start postfix. You can't just reload if you're changing inet_interfaces

  • I've tried the smtp_bind_address option but then my mail server doesn't send anymore mail. And I don't think inet_interfaces has to be changed since I don't want to receive mail on that server. Note, this IP is only used for sending mail.
    – aardbol
    Dec 8, 2009 at 19:34
  • Please post your postconf -n so we can see what you're talking about. Anonymize IPs as private IPs (10.x.x.x, etc) and domains as example.(com|net|org|whatever) if you feel you need to.
    – Bill Weiss
    Dec 8, 2009 at 20:26
  • 2
    smtp_bind_address was the right way and I just had a delay in email delivery since the new IP I was using had no rDNS record. Kind thanks for your help.
    – aardbol
    Dec 8, 2009 at 21:44
  • 4
    smtp_bind_address sets the IPv4 address, the IPv6 equivalent is smtp_bind_address6 Jan 22, 2016 at 6:52
  • note that inet_interfaces controls how postfix listens for (receives) mail and smtp_bind_address controls what IP postfix binds to for sending mail
    – Shelvacu
    Mar 12 at 6:40

If you use the "smtp_bind_address" solution then your mail server will only listen on that specified IP address for incoming mail as well. The same thing applies to the "inet_interfaces" solution. This may not be the desired soltution if you want to listen for incoming mail on multiple IP addresses/interfaces.

My solution is better, because I suggest not to change the default "smtp_bind_address" and "inet_interfaces" settings, so your mail server will still listen for incoming mail on all IP addresses.

Only need to make a small change in your /etc/postfix/master.cf file.

Change this part:

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

to this:

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

Of course, instead of you must use one of your IP addresses, the one you want to send your mail from.


  • I think that at the time I wanted the mail server to only listen to one IP address, for both incoming and outgoing email. But neverthless, I appreciate the extra info. Thanks.
    – aardbol
    Mar 19, 2013 at 22:41
  • 1
    will this work with ipv6? If so, can I include two addresses and bind to one of each? With this solution I am still getting outgoing mail over ipv6 and not the ipv4 address I have specified May 5, 2015 at 18:10
  • I added -o smtp_bind_address6=1:2:3:4:5:6:7:8 and seems to work. May 5, 2015 at 18:18
  • 2
    This isn't accurate. It is possible to make postfix listen on multiple interfaces via adding all of them to inet_interfaces - or just setting it to all (the default) and configuring smtp_bind_address. The one address specified via smtp_bind_address (or smtp_bind_address6) is then independently used for the Postfix smtp send process. Aug 6, 2016 at 12:34
  • I added the -o smtp_bind_address to my master.cf and it didn't work. I used it in main.cf and it did work. Jul 15, 2018 at 6:20


Create different Interfaces. One for each domain:

rotate1  unix -       -       n       -       -       smtp
          -o syslog_name=postfix-rotate1
          -o smtp_helo_name=domainone.com.br
          -o smtp_bind_address=

rotate2  unix -       -       n       -       -       smtp
          -o syslog_name=postfix-rotate2
          -o smtp_helo_name=domaintwo.com.br
          -o smtp_bind_address=


  1. Disable all other transport maps, i.e.: # transport_maps = xxxxx

  2. Enable dependent transport map (require postfix 2.7.x or later)

sender_dependent_default_transport_maps = mysql:/etc/postfix/config/transport_random_dependent.cf



user = postfix
password = mypassword
dbname = postfixdb
hosts = localhost
query = SELECT transport FROM transport_random WHERE domain = '%d' AND status='1' ORDER BY RAND() LIMIT 1

Table transport_random

Column "transport" = rotate1, rotate2, rotate3, rotate4 (etc)
Column "domain" = sender domains (replaced by %d)
Column "status" = boolean (0 or 1) if is enabled the transport.

The instruction "RAND() LIMIT 1" is necessary only if you want to use random transports for the same domain.

In example, you want to send from mydomain.com from 3 different IPs.

Then, you create 3 transports (rotate1, rotate2 and rotate3) with 3 different IPs, then set at mysql lines:

transport = rotate1 | domain = mydomain.com
transport = rotate2 | domain = mydomain.com
transport = rotate3 | domain = mydomain.com

Then, when postfix will randomize three different transports (rotate one to three) to send this emails.


Edit /etc/postfix/main.cf and make sure that the following line is present

inet_interfaces =, localhost

Then run "postfix reload"

  • 2
    This only sets the IP address to listen on for SMTP connections, and not the IP address to be used to send outgoing mail. Jul 26, 2015 at 6:20

If it's off a contiguous IP block given to you that hits your WAN gateway and you want to have a host use a different address than first one that shows on WAN, you will have to create a NAT/firewall solution. Ignore the rest of answers, if so. They're going about it the wrong way in that case.

And more generally, since this is for an email server, you definitely want a policy to force outgoing connections to reflect the chosen public IP you used. Otherwise reverse DNS checks, SPF checks, etc. will fail.

I usually don't post 3rd party/commercial websites as they tend to vanish, but similar to this:


^ Pretty easily applied to other firewalls/devices.

You will also need a policy to do the opposite as well. Only allow inbound traffic from the public IP you want to hit the given LAN server. But, you may have already figured that much out.

If needing to present (listening, or otherwise) more than one public IP from the actual server (www versus email in your case), the other approved answer here will work. Even so, you should still set your WAN<->NAT<->LAN up correctly, though as per above before configuring software side/postfix/apache/nginx/et al.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .