DMARC-Check unter Debian Wheezy 16


Wie ein DMARC-Record erstellt wird und warum das sinnvoll ist, habe ich schon in DMARC Rekord (Domain-based Message Authentication, Reporting & Conformance) beschrieben.
Jetzt geht es darum, einen solchen DMARC-Rekord bei der Einlieferung von Mails zu berücksichtigen. Die Überprüfung eines DMARC-Records erfordert gültige SPF und DKIM-Werte.
Zum Überprüfen von DKIM verwende ich opendkim. Durch opendmarc werden SPF und DMARC verifiziert.

Achtung: Wenn die DKIM-Signatur durch amavis überprüft werden soll, dann darf amavis nicht als smtpd_proxy_filter in postfix eingebunden sein. Das geht nur, wenn amavis als content_filter läuft.

Als erstes wird opendkim installiert:
apt-get install opendkim opendkim-tools

Unter Debian wird das Socket-File in der default-config hinterlegt:
echo 'SOCKET="inet:12345@localhost"' >> /etc/default/opendkim

Die Config /etc/opendkim.conf um ein paar Werte erweitern:
LogWhy yes
MilterDebug 0
Mode v
SyslogSuccess yes

Meine vollständige Config sieht so aus:
Syslog yes
UMask 002
OversignHeaders From
LogWhy yes
MilterDebug 0
Mode v
AuthservID mail.schaal-24.de
SyslogSuccess yes
AddAllSignatureResults true
AuthservIDWithJobID true
LogResults true
LogWhy true
SyslogSuccess true

Im Anschluß wird opendkim mit service opendkim restart neu gestartet.
Mit netstat -tap|grep dkim kann getestet werden, ob alles richtig läuft. Die Ausgabe sollte dann in etwa so aussehen:
tcp 0 0 localhost.localdo:12345 *:* LISTEN 1834/opendkim

Jetzt muss nur noch opendkim in postfix eingebunden werden:
vi /etc/postfix/main.cf

smtpd_milters = inet:127.0.0.1:12345
non_smtpd_milters = inet:127.0.0.1:12345

Und Postfix neu gestartet werden: service postfix restart

Die Installation von opendmarc ist etwas aufwändiger. Wir brauchen die dev-packages von libmilter
apt-get install libmilter-dev

und laden danach opendmarc herunter und installieren opendmarc in /usr

cd /tmp
wget -O - http://downloads.sourceforge.net/project/opendmarc/opendmarc-1.3.0.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fopendmarc%2F > opendmarc-1.3.0.tar.gz
tar xfvz opendmarc-1.3.0.tar.gz
cd opendmarc-1.3.0
./configure --prefix=/usr --with-spf --enable-live-tests
make
make install

Ein paar Änderungen sind noch erforderlich:

adduser --quiet --system --group --home /var/run/opendmarc opendmarc
chown opendmarc:opendmarc /var/run/opendmarc
echo 'SOCKET="inet:8893@localhost"' > /etc/default/opendmarc

Wir kopieren die Beispiel-Config und passen diese danach an.
cp /usr/share/doc/opendmarc/opendmarc.conf.sample /etc/opendmarc.conf
vi /etc/opendmarc.conf

Meine Config sieht gekürzt so aus:
AuthservID mail.schaal-24.de
AuthservIDWithJobID true
BaseDirectory /var/run/opendmarc
CopyFailuresTo dmarc-report@schaal-24.de
FailureReportsBcc dmarc-report@schaal-24.de
FailureReportsOnNone true
FailureReportsSentBy noreply-dmarc-report@schaal-24.de
HistoryFile /var/run/opendmarc/opendmarc.dat
IgnoreAuthenticatedClients true
IgnoreMailFrom schaal-24.de
PidFile /var/run/opendmarc.pid
RecordAllMessages false
SPFIgnoreResults true
SPFSelfValidate true
Syslog true
TrustedAuthservIDs mail.schaal-24.de
UserID opendmarc

Das .dat-Files muss noch angelegt und die Rechte entsprechend gesetz werden:
touch /var/run/opendmarc/opendmarc.dat
chown opendmarc.opendmarc /var/run/opendmarc/opendmarc.dat
chmod 600 /var/run/opendmarc/opendmarc.dat

Zuletzt brauchen wird noch ein Start-Script:
wget blog.schaal-24.de/files/opendmarc -O /etc/init.d/opendmarc
chmod +x /etc/init.d/opendmarc
update-rc.d opendmarc defaults

Opendmarc durch service opendmarc start starten und bei Bedarf durch netstat -tap|grep dmarc testen.

Als letztes wird opendmarc in Postfix integriert:

vi /etc/postfix/main.cf
smtpd_milters = inet:127.0.0.1:12345, inet:localhost:8893
non_smtpd_milters = inet:127.0.0.1:12345, inet:localhost:8893
und postfix neu gestartet: service postfix restart

Man kann eingehende Mails nicht nur hinsichtlich des DMARC-Records checken, sondern auch entsprechende Reports erstellen und verschicken. Dazu gibt es hier einen eigenen Beitrag.


Hinterlasse einen Kommentar zu jojo Antworten abbrechen

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind markiert *

16 Gedanken zu “DMARC-Check unter Debian Wheezy

  • Djerk Geurts

    Hi, any issues with following this on ISPConfig 3.1, assuming not if it worked fine with v3.0. This article was written nearly 2 years ago so trying to gauge how much has changed since.

  • Christophe D

    Hi, i try to configure opendmarc in my mail server (debian/postfix/amavis-new/opendkim…) and have this error

    Apr 18 00:21:47 greenhouse postfix/smtps/smtpd[28222]: warning: connect to Milter service inet:localhost:8893: Connection refused

    Thank for your tuto.

      • Christophe D

        yes opendkim run and sign mail with
        # nano -w /etc/default/opendkim

        SOCKET=”inet:8891@localhost”

        # nano -w /etc/default/opendmarc.conf

        SOCKET=”inet:8893@localhost”

        # nano /etc/postfix/main.cf

        smtpd_milters = inet:localhost:8893, inet:localhost:8891
        non_smtpd_milters = inet:localhost:8893, inet:localhost:8891

        • Christophe D

          i found … need to insert directly in /etc/opendmarc.conf
          the line :
          Socket inet:8893@localhost

          Thank you for your tuto and help

  • gesci

    In your tutorial the conf file /etc/opendmarc.conf you write : PidFile /var/run/opendmarc.pid it’s an error ? but in my other server it’s good ! the file is in /var/run/opendmarc/opendmarc.pid

  • gesci

    Helo thank’s for your patch it’s work well but i have this error Jan 20 14:54:43 (hostname) opendmarc[13041]: 015963E5236E: /var/run/opendmarc.dat: fopen(): Permission denied and permission are correct : drwxr-xr-x 2 opendmarc opendmarc 80 janv. 19 17:00 opendmarc

    • Florian Schaal Autor des Beitrags

      And the permissions for the files in /var/run/opendmarc? Should be 644 for opendmarc.opendmarc. Are you using a chrooted-setup?

      • gesci

        hello in my opendmarc.conf HistoryFile /var/run/opendmarc.dat changed to /var/run/opendmarc/opendmarc.dat (my error) chmod 644 -R /var/run/opendmarc/ and restarted service postfix et dmarc but i have same error :
        /var/run/opendmarc/opendmarc.dat: fopen(): Permission denied
        root@ns3323989:/var/run/opendmarc# ll
        total 0
        drw-r–r– 2 opendmarc opendmarc 60 janv. 21 11:41 .
        drwxr-xr-x 23 root root 840 janv. 21 00:31 ..
        -rw-r–r– 1 opendmarc opendmarc 0 janv. 21 11:42 opendmarc.dat
        chrooted setup how to ?

          • Florian Schaal Autor des Beitrags

            The init-script uses PIDFILE=$RUNDIR/$NAME.pid (/var/run/opendmarc/opendmarc.pid)

          • gesci

            hello i deleted folder and remake this and it’s work !!! thank’s for your support