Exim4 – Configuration to Use Multiple External IPs for Mail Sending

configurationeximlinux

i've got exim4 on ubuntu server and i-ve got a pool of 20 external IP's.

Is that possible to configure exim4 to use this ip-s rotating to send mail?


I think i could do this with iproute / iptables load balancing with "link stick" but i want to know if this is possible with exim4 internal configuration. Maybe there i should create several external smtp_drivers that will be using one of 20 IP and some random() func ?

Best Answer

I found this article which show how to sets up a random function to pick an IP from a list and then assign it as an output interface to the smtp driver.

Essentially, you have to set up a function:

sub randinet {
  @inet = ("x.x.x.1", "x.x.x.2", "x.x.x.3", "x.x.x.4");
  return $inet[int rand($#inet+1)];
}

and modify the smtp driver:

remote_smtp:
driver = smtp
interface = "${perl{randinet}}"
Related Topic