How to configure outgoing mailip rotation in exim
If we need to configure exim mail server to use multiple IPs for sending mail, follow the below custom configurations.
Please note that this will break “mailip” feature from cPanel (that allow users with dedicated IPs to send mail from these instead of main server IP). Also, if you enabled SPF, take care to add all new IP addresses to the list of allowed IPs.
Open the file /etc/exim.pl and add the below line somwhere at the end, above last line
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)];
}
Edit /etc/exim.conf and search for a line that start with “interface=”
remote_smtp:
driver = smtp
interface = ${if exists {/etc/mailips}{${lookup{$sender_address_domain}lsearch*{/etc/mailips}{$value}{}}}{}}
replace last line with
interface = "${perl{randinet}}"
You can do the same for dk_remote_smtp section (this is used for sending signed mails).
Finally restart exim service