Send all outgoing email trough one IP address in postfix

Tuesday, October 25, 2011 posted by Till

When a server has more then one IP address, then postfix will use all IP addresses randomly to send out emails. This can cause your emails to be listed as SPAM on other servers because the sending IP does not match the reverse IP of the server hostname. The solution is to bind postfix to the primary IP address of the server.

Edit the postfix main.cf file:

vi /etc/postfix/main.cf

and add the line:

smtp_bind_address = 192.168.0.1

were 192.168.0.1 has to be replaced with the primary IP address of the server. Then restart postfix:

/etc/init.d/postfix restart

Be Sociable, Share!



6 Responses to “Send all outgoing email trough one IP address in postfix”

  1. tyborall says:

    Leider ist die Lösung hier überhaupt nicht hilfreich. Wenn man unter ISPConfig 3 den Postfix wie angegeben konfiguriert werden die Mails von AMAVIS nicht mehr angenommen und es geht gar nichts mehr raus.

    Sinnvoller ist die folgende Anpassung in der /etc/postfix/master.cf:

    smtp unix – – – – – smtp
    -o smtp_bind_address=217.14.118.60
    127.0.0.1:25 unix – – – – – smtp

  2. Tom says:

    I need to do this (staring to get blocked by hotmail, aol, yahoo, etc – no reverse found, even though I have set it), and did it yesterday. Then I had no working mail. No mail was being processed or delivered. I also tried modifying the /etc/postfix/master.cf, which contained smptd_bind_address=127.0.0.1 to our principal server IP, and that did not help either. Connections were “lost” immediately after connection the logs show. Additionally amavis could not connect.

    In the master.cf file there is a line: 127.0.0.1:10025 for smptd, and there are lines referring to amavis with 127.0.0.1 see in both files, I believe. I don’t know if all references to 127.0.0.1 need to be changed to our main IP in both files, or not?

    Can you give any further advice on this, please? I have the “perfect server deb squeeze, courier postfix, fail2ban … set up the way your tutorial describes it with ISPConfig3.

    Thanks for any further advice.

    • David says:

      The lost error is from Amavis, as it wants to talk through 127.0.0.1 and not your smtp IP.

      In Debian the easiest way to fix this is by adding this to main.cnf:

      inet_interfaces = 192.168.1.1, 127.0.0.1
      smtp_bind_address = 192.168.1.1

      And create a file in /etc/amavis/conf.d/ (ie 60-custom) with is in it:

      @inet_acl = qw( 127.0.0.1 [::1] 192.168.1.1 );

      (where 192.168.1.1 is the IP you have postfix sending from)

      Restart Postfix and Amavis, and it should all work :)

  3. ShoShan says:

    simply thanks…
    It’s helped….

    Keep it up…

  4. gus says:

    Hi,

    instead of a primary ip address from the web server, could be a secondary ip address? I just do it and at the first sight, everything works well.

Leave a Reply