5

I got a server with 8 IP addresses to use as a mail server (With PostFix). I want PostFix to rotate the IP and hostname for each message. I found the config parameter

smtp_bind_address = 1.2.3.4

(And there's another one I can't remember that does hostname) But that only lets me bind to one IP/hostname.

Example;
I have these IP's:

1.1.1.1 => mail1.mydomain.com
1.1.1.2 => mail2.mydomain.com
1.1.1.3 => mail3.mydomain.com
[etc]

The first message should be sent from 1.1.1.1, second from 1.1.1.2, third from 1.1.1.3 etc. so just round-robin balancing the avaliable IPs

Is this possible with Postfix?

4
  • What problem are you trying to solve?
    – HTTP500
    Jul 8, 2011 at 16:30
  • @Jason It's to do with our internal mail servers. I'm not sure why but our incoming mail server will only accept a maximum of 100 emails from a single IP address per hour and the admins of that server aren't prepared to change that or white-list my servers. My application is a helpdesk app and needs to send a lot more than that so I just got a load of IPs to get around their block.
    – user80776
    Jul 8, 2011 at 16:40
  • @Jason I should probably have said, this is only for use on our internal network and will only send emails to people with email addresses on our domain
    – user80776
    Jul 8, 2011 at 16:41
  • 5
    This sort of of administrative stupidity (rate-limiting legitimate internal senders) pisses me off. You're not dealing with a technical problem here, you're dealing with a management one. I wouldn't try to fix a management problem with a technical kludge.
    – womble
    Jul 8, 2011 at 23:55

3 Answers 3

6

Postfix can't do that, but you could use iptables' SNAT target in conjunction with the statistics module to rotate your addresses. Something like this should do:

iptables -t nat -A POSTROUTING -p tcp --dport 25 -d <your_dest_mailserver> -m statistic --mode nth --every 8 -j SNAT --to 1.1.1.1
iptables -t nat -A POSTROUTING -p tcp --dport 25 -d <your_dest_mailserver> -m statistic --mode nth --every 8 -j SNAT --to 1.1.1.2
[...]
iptables -t nat -A POSTROUTING -p tcp --dport 25 -d <your_dest_mailserver> -m statistic --mode nth --every 8 -j SNAT --to 1.1.1.8
5

Take a look at the "Sender reputation" section of the Postfix 2.7 release notes. You might be able to bodge up something from it.

Otherwise, this post from the Postfix mailing list contains a statement from Wietse Venema stating that it will never be supported in Postfix. I agree with him, too -- if a recipient has put limits in place, you shouldn't try and work around them. If that causes the recipient problems, that's their problem.

2
  • Yes, but what if a server has to send any appreciable amount of mail to an org like AOL who sets ridiculously low rate limits and is too monolithic to ever listen to any complaints from either their users or other service providers?
    – Sammitch
    Sep 5, 2013 at 23:26
  • 2
    @Sammitch: "If that causes the recipient problems, that's their problem". You have the right to send e-mail, you do not have the right to force the recipient to receive it, and doing dodgy things like using round-robin IP addresses to get around the recipient's wishes counts as "forcing it" in my book.
    – womble
    Sep 6, 2013 at 6:08
0

No syneticon-dj, you are wrong, of course that postfix can do that:
see below examples:
http://marinovl.blogspot.com/2012/09/postfix-how-to-balance-outgoing-emails.html
http://www.kutukupret.com/2010/12/06/postfix-randomizing-outgoing-ip-using-tcp_table-and-perl/

2
  • 3
    Please do not post "link only" answers. Over time those sites might disappear and the answer becomes useless.
    – faker
    Aug 27, 2013 at 11:13
  • Also, this is not "postfix can do that".
    – Orphans
    Apr 19, 2021 at 14:03

You must log in to answer this question.