mikepk.com about current projects contact

Note: Exim Relay Split Configuration Under Ubuntu

March 3, 2010

airmail.pngI've been using exim under ubuntu for a while now, and while its split configuration system can be a little weird at times, overall I haven't had a problem. That is until I decided I wanted to be able to relay email from a machine on my local network. Several futile Google searches later, I still hadn't resolved my issue (and come across many posts of people seemingly having the same issue) so I thought I'd add a little note here.

I wanted to allow relays from one of my local hosts on a 192 network. In the past I've used an exim configuration variable: relay_from_hosts

So when I checked the split configuration files, I found it in /etc/exim4/conf.d/main/01_exim4-config_listmacrosdefs with the following statement:

hostlist relay_from_hosts = MAIN_RELAY_NETS

Huh? OK, so clearly there's some kind of variable being set, but where? Grep'ing the config files, I could only find where this was used and not set.

I was about to chuck the whole ubuntu exim install when finally, after a bunch of frustrating searching, I figured out that the ubuntu/debian config generator is what sets these macro definitions. That means you have to edit the config file config (huh?) found at /etc/exim4/update-exim4.conf.conf. Checking the man page for update-exim4.conf I found this gem:

In either case, before outputting the result to /var/lib/exim4/config.autogenerated, update-exim4.conf generates a number of exim configuration macros from the contents of dc_something from /etc/exim4/update-exim4.conf.conf and inserts them into the configuration right after the definition of the exim configuration macro UPEX4CmacrosUPEX4C (which is only used as placeholder for this case). The macro definitions are bracketed with .ifdef clauses to allow the local admin to override the values with earlier definitions. update-exim4.conf makes no other changes to the configuration. This makes it very simple to make small changes to the configuration and still have the benefits of debconf.

And of course further down in the man page is this bit:

A list of machines for which we serve as smarthost. Please note that and ::1 are always permitted to relay since /usr/lib/sendmail is available anyway and relay control doesn’t make sense here. Sets macro MAIN_RELAY_NETS.

So you set dc_relay_nets under update-exim4.conf.conf to the IP address of the machine you want to relay from. Then you do the split config dance and run update-exim4.conf and you should now be able to relay email from that IP (or range of IPs).

So I think I pulled something following their config logic.