Our thinking

Binding Dovecot and Exim to a specific IP on WHM/cPanel

If you’ve got a WHM/cPanel server, and you want to run an alternative mail server on one IP address and have Dovecot and Exim bound to another IP, it’s not as straightforward as you might first hope.

From what I can find, there’s scant documentation on explaining how to get Dovecot to behave, and no documentation whatsoever that explains how to get Exim to play nice.

If you were running a standard server, with off-the-shelf versions of the above packages, then it’s all very easy. WHM however makes things difficult by rebuilding config files and pulling in bits and pieces of data from all over the place when it does so. This means that if you know what change normally needs to be made to, say, /etc/exim.conf – you’re probably out of luck trying to change this as whenever the config reloads, or is changed in WHM, your changes will get wiped out.


Dovecot turned out to be the easier of the two to work out what to do.

Simply edit /var/cpanel/conf/dovecot/main and add listen: <your.ip.address> to the end of the file (obviously changing it for your desired IP address)


This was a real pain in the arse – there was absolutely no documentation on how to accomplish this within WHM, and in the end the fix was quite simple (as these things often are)

Edit /etc/exim.conf.local and in the @CONFIG@ section, add local_interfaces = : <your.ip.address>

You will often see examples of the local_interfaces directive having a value like so:

local_interfaces = <; ; ::1 ; 

In this case the <; after the = sign changes the item delimiter to ; from the default of : which we don’t need in this case as we’re not dealing with IPv6 addresses. We also don’t want to bind to as our other mail server is listening on this port.

Leave a Reply