Split MX with Exim

I've been having a rather strange exim setup for my grep.be domain since a while; but it works, and I like it, so I thought I'd document it.

There are two systems involved in the grep.be mail setup: samba.grep.be, a box which is on the public internet and which has a globally-valid IP address, and goa.grep.be, my Thecus N2100 that runs in my home network. The "home network server" used to be rock.grep.be, and western.grep.be before that, and folk.grep.be before that, but their exim config never was significantly different. None of those boxen ever had a fixed globally valid IP address.

You'd think I'm defining my accounts on goa, and have samba just be a secondary MX. Well, almost. I also run a bunch of mailinglists, and running those on my private network would be a waste of bandwidth; that'd require me to have the mails come though my cable modem to get to the mailinglist manager, then to get processed by the last, and then to get through the cable modem again for quite a number of times. Some of these mailinglists used to be quite... traffic-intense... and I didn't like the loss of almost all my Internet connectivity when a mail was being sent out. However, I hadn't been smart enough to remember to get my lists in a separate subdomain; instead, both regular mail accounts and mailinglist addresses are simple @grep.be addresses. I could of course have reorganized everything, but I didn't want to do that if not absolutely necessary. And after thinking about it for a while, I came up with this:

On goa, the exim config contains the following in the acl_smtp_rcpt acl:

accept hosts   = 195.144.77.39
       domains = +local_domains
       endpass
       message = unknown user
       verify  = recipient

accept domains = +local_domains
       endpass
       verify  = recipient/callout=random/no_details

And on samba, it contains the reverse:

accept hosts    = +goa_hosts
       domains  = +local_domains
       endpass
       message  = unknown user
       verify   = recipient

require domains = +local_domains
	endpass
	verify  = recipient/callout=random/no_details

with +goa_hosts being a hostlist that defines the IP address(es) that goa may use to connect to samba.

The idea is that when an SMTP connection is initiated with samba, it will first check whether it knows the mailadres by verifying whether it just happens to be a mailinglist. If it is, then it sends it to the mailinglist. If not, it will connect to goa to verify whether the local part is know to goa -- unless the SMTP connection happens to be originating from goa itself. Goa does the same thing, but in reverse.

This way, samba can bounce unknown users at the SMTP stage, rather than having to accept them and then bounce them, as would be the case if I didn't have this setup.

Obviously the possible IP addresses by which goa can connect to samba (and vice versa) must be perfectly maintained, otherwise you create mail loops. Since goa is on an IP address that tends to change from time to time, I set this in a hostlist in my exim.conf, so that I only need to change it once if the IP address changes.

I'm pretty happy about my exim setup, even if it isn't perfect. There are still a number of things I'd like to do; one of them is writing a tool to parse my /var/log/exim4/mainlog to find hosts that have been trying to abuse my server, so that I can blacklist them for a few days.

Update:

done