Yes, as I mentioned, Hestia configures Exim4 to use this /home/USER/conf/mail/DOMAIN/ip
to determine the outgoing IP for a domain. Since Hestia automatically updates this file based on the web domain’s IP, any manual changes you make to the file will be overwritten whenever the mail domain is rebuilt.
You could try making the file immutable using chattr +i /home/USER/conf/mail/DOMAIN/ip
, but this would cause rebuilds of the mail domain to fail, making it an invalid solution. Without modifying Hestia’s code, a better approach would be to create a new outgoing ip file, such as mainip
, and configure Exim to prioritize it. If the mainip
file exists, Exim will use it instead of the ip
file for the outgoing IP configuration.
To implement this, modify the Exim configuration file /etc/exim4/exim4.conf.template
as follows:
Replace this line:
OUTGOING_IP = /etc/exim4/domains/${lookup{$sender_address_domain}dsearch{/etc/exim4/domains}}/ip
With this:
OUTGOING_IP = /etc/exim4/domains/${lookup{$sender_address_domain}dsearch{/etc/exim4/domains}}/${if exists{/etc/exim4/domains/${lookup{$sender_address_domain}dsearch{/etc/exim4/domains}}/mainip}{mainip}{ip}}
Then restart Exim with the following command:
systemctl restart exim4
With this setup, you can create a file /home/USER/conf/mail/DOMAIN/mainip
containing the desired IP for the domain. Exim will use this file for the outgoing IP. This approach ensures that you don’t need to modify the primary IP for the web domain, and it avoids issues during mail domain rebuilds.
Note: the mainip
file must have the right owner/group/perms.
Example using ip 203.0.113.1
echo '203.0.113.1' > /home/USER/conf/mail/DOMAIN/mainip
chown Debian-exim:mail /home/USER/conf/mail/DOMAIN/mainip
chmod 660 /home/USER/conf/mail/DOMAIN/mainip
Maybe there is a more elegant solution but this should work.
Disclaimer: You should run tests before implementing this solution in production 