No control panel equivalent of exim /etc/mailips file for configuring IPs for each domain's outgoing mail?
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?
Solution 1:
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:
- Find your exim config file,
exim.conf
. They suggest/etc/exim.conf
, mine was in/etc/exim/exim.conf
- Create a file to store domain - IP associations. I went with
/etc/exim/domainips
, they favoured/etc/virtual/domainips
- Fill it with domains and IPs like this:
some-domain.com: 123.123.123.123
anotherdomain.org: 98.98.98.98
- In the
exim.conf
file, find the sectionremote_smtp:
- If there's an
interface = some.ip.add.ress
line belowremote_smtp:
, remove it. - Add a line using the file name from before:
interface = "${lookup{$sender_address_domain}lsearch{/etc/exim/domainips}{$value}}
- 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