OpenDMARK Report (Ubuntu 18.04): Unterschied zwischen den Versionen
(→Script) |
|||
(13 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
Zeile 1: | Zeile 1: | ||
== Voraussetzungen == | == Voraussetzungen == | ||
Zeile 32: | Zeile 29: | ||
</pre> | </pre> | ||
Danach das Verzeichnis dafür erstellen: | Danach das Verzeichnis dafür (+ für Reports) erstellen: | ||
<pre> | <pre> | ||
sudo mkdir -p /var/spool/opendmarc/ | sudo mkdir -p /var/spool/opendmarc/reports | ||
sudo chown opendmarc:opendmarc /var/spool/opendmarc/ | sudo chown -R opendmarc:opendmarc /var/spool/opendmarc/ | ||
sudo chmod | sudo chmod -R 775 /var/spool/opendmarc/ | ||
</pre> | </pre> | ||
Zeile 56: | Zeile 53: | ||
</pre> | </pre> | ||
Danach die herunter geladenen SQL-Patches anpassen | Danach die herunter geladenen SQL-Patches anpassen: | ||
<pre> | <pre> | ||
Zeile 62: | Zeile 59: | ||
cp /usr/share/doc/opendmarc/schema.mysql . | cp /usr/share/doc/opendmarc/schema.mysql . | ||
vi schema.mysql | vi schema.mysql | ||
</pre> | |||
Am Ende die 2 Zeilen für den Benutzer anpassen: | |||
<pre> | |||
CREATE USER 'opendmarc'@'%' IDENTIFIED BY '<password>'; | |||
GRANT ALL ON opendmarc.* to 'opendmarc'@'%'; | |||
</pre> | |||
Die angepasste Datei mittels folgenden Befehl ausführen: | |||
<pre> | |||
mysql -u root -p < schema.mysql | |||
</pre> | |||
=== Script === | |||
Hinweis: die Mail-Adresse <code>dmarc-report@<domain></code> muss angelegt werden. | |||
Das Script <code>create_opendmarc_report.sh</code> erstellen | |||
<pre> | |||
sudo vi /usr/local/bin/create_opendmarc_report.sh | |||
</pre> | |||
und mit folgendem Inhalt befüllen (Variablen anpassen): | |||
<pre> | |||
#!/bin/bash | |||
# Script to create DMARC reports | |||
DAT_FILE=/var/spool/opendmarc/opendmarc.dat | |||
REPORT_EMAIL=dmarc-report@kirner.or.at | |||
REPORT_DIR=/var/spool/opendmarc/reports/ | |||
export OPENDMARC_DBHOST=10.0.0.156 # default localhost | |||
export OPENDMARC_DB=opendmarc # default opendmarc | |||
export OPENDMARC_PASSWORD=<password> # default opendmarc | |||
export OPENDMARC_USER=opendmarc # default opendmarc | |||
case $1 in | |||
import) | |||
if [ -e $DAT_FILE ]; then | |||
/usr/sbin/opendmarc-import < $DAT_FILE &> /dev/null | |||
fi | |||
;; | |||
report) | |||
if [ ! -d "$REPORT_DIR" ]; then mkdir -p $REPORT_DIR; fi | |||
cd $REPORT_DIR | |||
/usr/sbin/opendmarc-reports --day --keepfiles --verbose --report-email $REPORT_EMAIL | |||
;; | |||
expire) | |||
/usr/sbin/opendmarc-expire --expire=90 | |||
;; | |||
*) | |||
echo use "import", "report" or "expire" | |||
;; | |||
esac | |||
</pre> | |||
Danach wieder Besitzer anpassen und ausführbar machen: | |||
<pre> | |||
sudo chown opendmarc:opendmarc /usr/local/bin/create_opendmarc_report.sh | |||
sudo chmod 750 /usr/local/bin/create_opendmarc_report.sh | |||
</pre> | |||
== Cron-Jobs == | |||
{{note|Noch nicht hinzugefügt.}} | |||
<pre> | |||
# dmarc | |||
0 */2 * * * /root/scripts/dmarc.sh import | |||
15 0 * * * /root/scripts/dmarc.sh report | |||
0 1 * * * /root/scripts/dmarc.sh expire | |||
</pre> | </pre> | ||
Aktuelle Version vom 29. März 2020, 18:11 Uhr
Voraussetzungen
OpenDMARK muss bereits installiert sein.
Konfiguration
Datei für Roh-Daten
Die Datei
sudo vi /etc/opendmarc.conf
bearbeiten und am Ende folgenden Parameter hinzufügen:
## HistoryFile path ## default (none) ## ## If set, specifies the location of a text file to which records are written ## that can be used to generate DMARC aggregate reports. Records are groups ## of rows containing information about a single received message, and ## include all relevant information needed to generate a DMARC aggregate ## report. It is expected that this will not be used in its raw form, but ## rather periodically imported into a relational database from which the ## aggregate reports can be extracted by a tool such as opendmarc-import(8). HistoryFile /var/spool/opendmarc/opendmarc.dat
Danach das Verzeichnis dafür (+ für Reports) erstellen:
sudo mkdir -p /var/spool/opendmarc/reports sudo chown -R opendmarc:opendmarc /var/spool/opendmarc/ sudo chmod -R 775 /var/spool/opendmarc/
Zum Abschluss den Service wieder neustarten:
sudo systemctl restart opendmarc.service
Datenbank
Da bei mit die Datei /usr/share/doc/opendmarc/schema.mysql
gefehlt hat, musste ich sie erst von https://sources.debian.org/src/opendmarc/1.3.2-7/db/ runterladen (mittels opendmarc -V
die Versin prüfen):
cd /usr/share/doc/opendmarc/ sudo wget https://sources.debian.org/data/main/o/opendmarc/1.3.2-7/db/schema.mysql sudo wget https://sources.debian.org/data/main/o/opendmarc/1.3.2-7/db/update-db-schema.mysql
Danach die herunter geladenen SQL-Patches anpassen:
cd ~/temp cp /usr/share/doc/opendmarc/schema.mysql . vi schema.mysql
Am Ende die 2 Zeilen für den Benutzer anpassen:
CREATE USER 'opendmarc'@'%' IDENTIFIED BY '<password>'; GRANT ALL ON opendmarc.* to 'opendmarc'@'%';
Die angepasste Datei mittels folgenden Befehl ausführen:
mysql -u root -p < schema.mysql
Script
Hinweis: die Mail-Adresse dmarc-report@<domain>
muss angelegt werden.
Das Script create_opendmarc_report.sh
erstellen
sudo vi /usr/local/bin/create_opendmarc_report.sh
und mit folgendem Inhalt befüllen (Variablen anpassen):
#!/bin/bash # Script to create DMARC reports DAT_FILE=/var/spool/opendmarc/opendmarc.dat REPORT_EMAIL=dmarc-report@kirner.or.at REPORT_DIR=/var/spool/opendmarc/reports/ export OPENDMARC_DBHOST=10.0.0.156 # default localhost export OPENDMARC_DB=opendmarc # default opendmarc export OPENDMARC_PASSWORD=<password> # default opendmarc export OPENDMARC_USER=opendmarc # default opendmarc case $1 in import) if [ -e $DAT_FILE ]; then /usr/sbin/opendmarc-import < $DAT_FILE &> /dev/null fi ;; report) if [ ! -d "$REPORT_DIR" ]; then mkdir -p $REPORT_DIR; fi cd $REPORT_DIR /usr/sbin/opendmarc-reports --day --keepfiles --verbose --report-email $REPORT_EMAIL ;; expire) /usr/sbin/opendmarc-expire --expire=90 ;; *) echo use "import", "report" or "expire" ;; esac
Danach wieder Besitzer anpassen und ausführbar machen:
sudo chown opendmarc:opendmarc /usr/local/bin/create_opendmarc_report.sh sudo chmod 750 /usr/local/bin/create_opendmarc_report.sh
Cron-Jobs
Noch nicht hinzugefügt.
# dmarc 0 */2 * * * /root/scripts/dmarc.sh import 15 0 * * * /root/scripts/dmarc.sh report 0 1 * * * /root/scripts/dmarc.sh expire
Links
https://blog.schaal-24.de/mail/dmarc-reports-erstellen/
Zurück zu OpenDMARK