User Tools

Site Tools


setup:mx

This is an old revision of the document!


Mail server infrastructure setup on debian wheezy

This section is being redacted

Primary Postfix Setup

MySQL

Setup milters

Some personnal advices about milters and mail filters:

  • DO use Unix sockets instead of Inet ones: Unix sockets use less ressources and are faster because of the internal components involved (inet sockets uses IP & TCP, which generate some overhead. Even if you use inet socket, you may not sense a difference if you don't generate a lot of trafic).
  • Prefer use of milters over classic content filters: configuration may be more tricky sometimes, but it is worth its weight in gold if you don't have advanced filtering to do. Amavis is heavy, and basic filtering can be handled by maildrop (configuration will be done after this).

SPF (Sender Policy Framework)

Natively available in the wheezy repository, this milter configuration is a bit tricky. To begin the install process, type the following commands.

apt-get install spf-milter-python
mkdir -p /var/spool/postfix/var/run/spf-milter-python
chown spf-milter-python:spf-milter-python /var/spool/postfix/var/run/spf-milter-python
ln -s /var/spool/postfix/var/run/spf-milter-python /var/run/spf-milter-python
adduser postfix spf-milter-python

Change the socket name as follow in /etc/spf-milter-python/spfmilter.cfg

socketname = /var/run/spf-milter-python/spfmilter.sock

Edit /etc/init.d/spf-milter-python to add the following lines after the “start-stop-daemon” commands in sections start and restart. Replace the socket definition by SOCKET=$RUNDIR/spfmilter.sock, and

        sleep 5
        chmod g+w $SOCKET

Restart the spf-milter-python service.

Add the milter socket unix:/var/run/spf-milter-python/spfmilter.sock in /etc/postfix/main.cf (an example is given below):

smtpd_milters = unix:/var/run/spf-milter-python/spfmilter.sock

You must put this filter before opendmarc (DMARC validation won't be done if you don't do it), and you should put it before spamass-milter socket (SPF validation contributes to spam flagging).

DKIM (DomainKeys Identified Mail)

This part has been inspired by the following tutorial: http://blog.tjitjing.com/index.php/2012/03/guide-to-install-opendkim-for-multiple-domai ns-with-postfix-and-debian.html Guide to Install OpenDKIM for multiple domains with Postfix and Debian

To begin with, type

apt-get install opendkim opendkim-tools
adduser postfix opendkim
mkdir -p /var/spool/postfix/var/run/opendkim/
chown opendkim:opendkim /var/spool/postfix/var/run/opendkim/

Edit /etc/default/opendkim to set the socket as follow:

SOCKET="local:/var/spool/postfix/var/run/opendkim/opendkim.sock"

Edit /etc/opendkim.conf and add the following lines:

KeyTable                /etc/opendkim/KeyTable
SigningTable            /etc/opendkim/SigningTable
ExternalIgnoreList      /etc/opendkim/TrustedHosts
InternalHosts           /etc/opendkim/TrustedHosts

In the same file, edit the socket permission mask as follow:

UMask 0002

You should uncomment/add the following lines to get some debugging informations.

Syslog yes
LogWhy yes

Check also that the line OversignHeaders From is uncommented, then save and close the file.

Domain Keys generation

Next step is to generate the DKIM keys that will be used to sign the mails going out of your domains. The following commands are given for domain.com:

mkdir -p /etc/opendkim/keys/mydomain.com
cd /etc/opendkim/keys/mydomain.com
opendkim-genkey -b 3072 -r -d mydomain.com
chown opendkim:opendkim default.private

Then add the following line to /etc/opendkim/KeyTable:

default._domainkey.mydomain.com mydomain.com:default:/etc/opendkim/keys/mydomain.com/default.private

and the following line in /etc/opendkim/SigningTable:

mydomain.com default._domainkey.mydomain.com
Insert DKIM key into the appropriate DNS Zone

You will find the appropriate record in /etc/opendkim/keys/mydomain.com/default.txt. You should secure your DNS zone with DNSSEC to enhance your immunity to DNS records spoofing. Start opendkim service and double-check that it is started at each reboot.q

Install the filter socket in postfix

Add the milter socket unix:/var/run/spf-milter-python/spfmilter.sock in /etc/postfix/main.cf (an example is given below) in both 'smtpd_milters and non_smtpd_milters'' section (e.g below):

smtpd_milters = unix:/var/run/spf-milter-python/spfmilter.sock unix:/var/var/run/opendkim/opendkim.sock
non_smtpd_milters = unix:/var/var/run/opendkim/opendkim.sock

You must put this filter before opendmarc (DMARC validation won't be done if you don't do it), and you should put it before spamass-milter socket (DKIM validation contributes to spam flagging).

DMARC (Domain-based Message Authentication, Reporting & Conformance)

http://dmarc.org/ DMARC is a technical specification that enables you fight the spam more efficiently. It enables:

  • A security policy enforcement (quarantine or reject) when a DMARC-compliant server receives fraudulent email (detected using SPF policy violation or DKIM signature failure).
  • Collecting feedback data. This is pretty useful to identify from where threats come from, and to set up a mitigation policy.

The stable version of this module is in debian unstable repository. Enable the unstable repository (and pin it to avoid an upgrade to unstable).

apt-get install -t unstable opendmarc

Emergency Postfix Setup

setup/mx.1369469076.txt.gz · Last modified: 2013/05/25 10:04 by root

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki