One of the biggest problems for servers with multiple domains is that exim doesn't "know" about them and instead acts as the main server for all of them.
As a result, when you connect to the mail server of "resolddomain.com" (port 25) you'll see
something like:
220-maindomain.com ESMTP Exim 4.63 #1 Sat, 26 May 2007 10:09:20 +0000
instead, that should have been:
220-resolddomain.com ESMTP Exim 4.63 #1 Sat, 26 May 2007 10:09:20 +0000
The above is for incoming connections. Unfortunately outgoing connections are more important and what happens there is that exim doesn't use the dedicated IP address of the sender, instead it uses the reseller/main IP address of the server. Which means that ALL the domains on your server will be sending out emails from the SAME IP address.
If a single domain is blocked by a RBL like SpamCop then that will affect your entire system and all your domains.
So here is the best method to solve this problem:
STEP 1 - Requirements
We require two files, one has the association "dedicated IP address -> domain" and the other has the reverse "domain -> dedicated IP address". The first file already exists if you are using cPanel/WHM, its automatically created and maintained. In these files you have to list ALL your dedicated IP addresses and their corresponding domain names, only those will be detected by exim.
Create the first file (IP -> domain): /etc/domainips
Format is:
IP: domain
(remember, if you are using cPanel/WHM this file already exists and its maintained automatically!!)
Create the second file (domain -> IP): /etc/domainips_reverseCode:192.168.1.1: resolddomain.com 192.168.2.2: anotherdomain.com etc...
Format is:
domain: IP
You may also use the following script to generate the domainips_reverse file automatically (thanks to Ron for coding it):Code:resolddomain.com: 192.168.1.1 anotherdomain.com: 192.168.2.2 etc...
Code:/bin/sed 's/\(.*\)\(: \)\(.*\)/\3: \1/' </etc/domainips | /bin/sort >/etc/domainips_reverse
STEP 2 - Exim configuration - Incoming connections
Unfortunately there is no "future proof" way of doing this. Any changes we make now may be overwritten by a future update via RPM or similar (cPanel/WHM automatically install updates). The best way is to make your changes, keep them in a separate file and when an exim update overwrites your exim.conf then you should manually re-enter them.
First change is for incoming connections, it modifies the hello message seen by clients and confirms they are connected to the correct server/domain.
Edit your /etc/exim.conf, search for the string "perl_startup" and below it, enter the following line (the second line correctly generates the message-id header):
Search for the string "smtp_banner" and replace that line with:Code:smtp_active_hostname = ${lookup{$interface_address}lsearch{/etc/domainips}{$value}{$primary_hostname}} message_id_header_domain = $smtp_active_hostname
Code:smtp_banner = "${smtp_active_hostname} ESMTP Exim ${version_number} \
STEP 3 - Exim configuration - Outgoing connections
Again edit your /etc/exim.conf, now search for the string "remote_smtp:" (note the semi-colon at the end of the string).
You should find something like:
change it to:Code:remote_smtp: driver = smtp
Since cPanel version 11, you need to do this once more (since v11 adds DomainKeys):Code:remote_smtp: driver = smtp interface = ${lookup{$sender_address_domain}lsearch{/etc/domainips_reverse}{$value}{$interface_address}} helo_data = ${lookup{$interface_address}lsearch{/etc/domainips}{$value}{$primary_hostname}}
Find "dk_remote_smtp", it should be a few lines below the above remote_smtp line:
change it to:Code:dk_remote_smtp: driver = smtp dk_private_key = "/var/cpanel/domain_keys/private/${dk_domain}" dk_canon = nofws dk_selector = default
Code:dk_remote_smtp: driver = smtp interface = ${lookup{$sender_address_domain}lsearch{/etc/domainips_reverse}{$value}{$interface_address}} helo_data = ${lookup{$interface_address}lsearch{/etc/domainips}{$value}{$primary_hostname}} dk_private_key = "/var/cpanel/domain_keys/private/${dk_domain}" dk_canon = nofws dk_selector = default
STEP 4 - Received lines
One last thing remaining, the Received: lines also contain the primary hostname. The following code should use the virtual domain like the above lines and will fall back to the primary hostname if the virtual domain isn't using a dedicated IP and/or not listed in the domainips files.
Seach for the "smtp_banner" string and below it add the following (as of Exim 4.68):
Code:received_header_text = Received: \ ${if def:sender_rcvhost {from $sender_rcvhost\n\t}\ {${if def:sender_ident \ {from ${quote_local_part:$sender_ident} }}\ ${if def:sender_helo_name {(helo=$sender_helo_name)\n\t}}}}\ by $smtp_active_hostname \ ${if def:received_protocol {with $received_protocol}} \ ${if def:tls_cipher {($tls_cipher)\n\t}}\ (Exim $version_number)\n\t\ ${if def:sender_address \ {(envelope-from <$sender_address>)\n\t}}\ id $message_exim_id\ ${if def:received_for {\n\tfor $received_for}}
STEP 5 - Misc notes & Warnings
What we've done here, is make exim look for dedicated IP address and their corresponding domain names in two text files.
If a match is found then exim will behave like all incoming and outgoing connections are from that dedicated IP address and domain.
Two things are of great importance:
1. You must manually maintain the two text files (in case of cPanel/WHM its one file), otherwise any new domains won't be found by exim.
2. A future Exim update will delete all your changes, so keep a copy of the modified file or the modifications you've made.
I believe its obvious that the whole thing only works with DEDICATED IP ADDRESSES. Any domain using the shared IP address of the server will just keep on using that. As it should really.
Version changes of this document:
1.5 - Added minor spelling correction and extra DK lines
1.4 - Added received line
1.3 - Added header_id update to show correct domain
1.2 - Added Ron's script to generate domainips_reverse
1.1 - Added cPanel v11 specific changes
1.0 - Initial version


LinkBack URL
About LinkBacks



Reply With Quote


Bookmarks