I have a problem with outgoing SMTP mail being sent with the wrong IP address.

I use exim for outgoing mail. I found a guide "How to manually configure Exim's outgoing IP addresses", which suggests modifying /etc/mailips. This file looks like exactly what I'm looking for.

Unfortunately the file doesn't exist on my server. On closer examination, I believe that file is not part of normal exim configuration but is created by a certain proprietary control panel package to ease configuring exim. I can't find any direct equivalent in exim.

How can I configure the IP address for outgoing mail for each domain in exim?


It appears that file is indeed something created by a certain proprietary control panel package.

The good news is, it's easy to roll your own. Exim config can fix an IP address with the interface property. In theory, it's one IP per server, but a little code can make it dynamic.

This is adapted from a loginroot article:

  1. Find your exim config file, exim.conf. They suggest /etc/exim.conf, mine was in /etc/exim/exim.conf
  2. Create a file to store domain - IP associations. I went with /etc/exim/domainips, they favoured /etc/virtual/domainips
  3. Fill it with domains and IPs like this:


  1. In the exim.conf file, find the section remote_smtp:
  2. If there's an interface = some.ip.add.ress line below remote_smtp:, remove it.
  3. Add a line using the file name from before:

  interface = "${lookup{$sender_address_domain}lsearch{/etc/exim/domainips}{$value}}

  1. Restart exim. service exim restart worked for me (Centos), or an alternative is /etc/init.d/exim restart

This then grabs the IP from the file for each email as it's sent, based on the sender domain.

Note: as well as working in control-panel-free systems, this also appears to work with Vesta CP

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.