Some of our servers have multiple IP addresses configured - in most cases we want to use eth0:1 rather than eth0, but it wasn’t immediately clear how to do this on cPanel’s Exim mail server.

The original solution was to modify /etc/exim.conf, but today I discovered that there is a specific file (``/etc/mailips`) where IPs can be specified per-domain or globally.

To get this working, just setup /etc/mailips as follows:

<domain>: <ip>
<domain2>: <ip>

Obviously, you need to replace <domain> and <ip> with the appropriate entries. In my case, this wasn’t ideal as I wanted to use a single IP globally. Luckily, that’s easily done by using an asterisk (*) for <domain>. I believe it even works alongside specific domain entries, so you could have certain domains sending mail out on unique IPs, and then globally route everything else through another.

Once that file has been edited, you need to modify the cPanel Exim configuration by going to Exim Configuration Editor within WHM. If you search for mailips on that page, you’ll see which box you need to check (don’t forget to save afterwards).