use postfix to setup a satellite host and maquerading

Date Tags postfix

It’s actually pretty easy. On the client side you need to specify your hostname, your origin and the relay host. For example:

myhostname = dev.localnet.xen
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
#mydestination = dev.localnet.xen, dev, localhost
relayhost = [mail.localnet.xen]
mynetworks = 127.0.0.0/8

Mydestination must not be set otherwise mail will be delivered locally. Server side you need first rewrite the from field of every email coming from the satellite host. This is necessary in my case as I’m using a local domain that is unknown to the relay host and that will cause a rejection with “unknown domain”. Secondly you would need to rewrite the To field of the email to deliver it either locally of send it somewhere else.

in brief:

mydestination = dev.localnet.xen
[...]
canonical_maps = regexp:/etc/postfix/canonical.regex
virtual_alias_maps = hash:/etc/postfix/virtual

Mydestination is to accept the email from the satellite host, the canonical_maps is to rewrite the From and the virtual_maps are to rewrite the To field.

For the canonical maps I use a regexp to match all my satellite hosts at once and rewrite them to $user-$host@example.net . For example:

/^(.*)@(.*)\.localnet\.xen$/ $(1)-$(2)@example.net

configuring sympa with postfix

Last week I took over the task of migrating sympa from a vserver machine to a xen vm. In the process I upgraded the sympa version and changed the MTA, from sendmail (ahhhhhhhhhh) to postfix. In my opinion sympa is designed to do far too many things just to be a mailing list manager. In particular, it has its own mail spool, it organizes mail delivering (via the MTA) and bounces.

Because of this design, the easiest way to configure it to work with postfix is to use it as a transport and let it do whatever … The problem with this configuration is that postfix doesn’t have any mean to know, for a give domain, which user (mailing list) is legal and which one is not. To get around this problem, one solution is to remove the local recipient check setting local_recipient_maps to empty. However this way, postfix will accept all emails, and subsequently generate a bounce if the local user doesn’t really exists. This can be used my spammers and it’s a very bad idea. The postfix manual explains this very well is bold.

To get around this problem, my simple solution then is to generate a postfix map to give back to postifx a bit more of control over this business.

Now, my local_recipient_maps looks like:

local_recipient_maps = $alias_maps, hash:/etc/postfix/sympa-recipients

and this is a small script I run every now and then to re-generate the hash table.

#!/bin/sh

for i in `ls /var/lib/sympa/expl/sympa.pps.jussieu.fr`; do 
    echo "$i unsed"; 
done > /etc/postfix/sympa-recipients
postmap /etc/postfix/sympa-recipients

/etc/init.d/postfix reload

for reference, this is the error you would get without local_recipient_maps.

sympa postfix / smtpd [12345]: NOQUEUE: reject: RCPT from xxxxxxxxxxx[xxx.xxx.xxx.xxx]: 550 5.1.1 test123@sympa.xxxx.org: Recipi ent address rejected: User unknown in local recipient table; from=me@ ex.org to=test123@sympa.xxxx.org proto=ESMTP helo=