Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
    
What problem are you trying to solve? –  HTTP500 Jul 8 '11 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. –  sam Jul 8 '11 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 –  sam Jul 8 '11 at 16:41
4  
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 '11 at 23:55
add comment

3 Answers

up vote 5 down vote accepted

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
share|improve this answer
add comment

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.

share|improve this answer
    
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 '13 at 23:26
1  
@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 '13 at 6:08
add comment

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/

share|improve this answer
    
Please do not post "link only" answers. Over time those sites might disappear and the answer becomes useless. –  faker Aug 27 '13 at 11:13
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.