I want to loadbalance outbound emails via multiple IPs, is there any built-in tool or some easy way to do it with postfix, sendmail or exim? for example if I assign three IPs to the email server and emails are sent via all the ips one by one.
I want to loadbalance outbound emails via multiple IPs, is there any built-in tool or some easy way to do it with postfix, sendmail or exim? for example if I assign three IPs to the email server and emails are sent via all the ips one by one.
With Postfix 2.7 or later it's pretty easy.
First create one entry for each IP in master.cf, like this:
Then create a sender dependent transport map in main.cf, like this:
Comment out all the other transport_maps in main.cf, like this:
Now here is the trick, this transport table will be using RAND() to randomize usage of all the out[1..n] transports listed in master.cf.
In /etc/postfix/config/transport_roundrobin.cf write:
Finally, create a table called 'transport_roundrobin' on db 'dbname' running on 'dbhost' and insert one row for each transport:
Postfix will select a random row from the transport_roundrobin mysql table and then use the value obtained to select the corresponding transport in master.cf. Each transport will use a different ip address, according to -o smtp_bind_address
If you want send mails from different Ip's from a single mail server than you should think about postfix multiple instance on a single host. And you can assign a different Ip address for each instance and your null instance will submit mails for each instance. for more detail you may refer these links This one for how to assign Ip and all http://souptonuts.sourceforge.net/postfix_sbr.html and this for all basic information how we create and how instance works http://www.postfix.org/MULTI_INSTANCE_README.html
Check this solution if using postfix 3, it uses randmap, so you won't need mysql's
RAND()
function. https://shami.blog/2016/04/randomize-source-ip-addresses-with-postfix/You can do the
master.cf
config suggested already, and add the following themain.cf
(assuming you have 3 entries inmaster.cf
):