Rspamd Einrichten: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
(→Tests) |
|||
| Zeile 117: | Zeile 117: | ||
Message-ID: undef | Message-ID: undef | ||
Message - smtp_message: Matched map: LOCAL_RBL_HIT | Message - smtp_message: Matched map: LOCAL_RBL_HIT | ||
| + | </pre> | ||
| + | |||
| + | =Clamav einbinden= | ||
| + | *cat /etc/rspamd/local.d/antivirus.conf | ||
| + | clamav { | ||
| + | servers = "127.0.0.1:3310" | ||
| + | #Unix Socket | ||
| + | #servers = "/run/clamav/clamd.ctl" | ||
| + | } | ||
| + | |||
| + | |||
| + | ==== Aktivierung von ClamAV in Rspamd Muss noch getestet werden==== | ||
| + | Rspamd muss angewiesen werden, ClamAV für Virenprüfungen zu nutzen. Dazu wird die Datei `local.d/antivirus.conf` bearbeitet: | ||
| + | |||
| + | <pre> | ||
| + | vi /etc/rspamd/local.d/antivirus.conf | ||
| + | </pre> | ||
| + | |||
| + | Konfiguration für ClamAV: | ||
| + | <pre> | ||
| + | clamav { | ||
| + | servers = "127.0.0.1:3310"; | ||
| + | # Oder alternativ via UNIX-Socket: | ||
| + | # servers = "/run/clamav/clamd.ctl"; | ||
| + | } | ||
| + | </pre> | ||
| + | |||
| + | == Reaktionen auf ClamAV-Ergebnisse anpassen == | ||
| + | *Falls ClamAV ein Makro (`CLAM_VIRUS_MACRO`) oder ein verschlüsseltes Attachment (`CLAM_VIRUS_ENCRYPTED`) erkennt, wird standardmäßig keine Ablehnung durchgeführt. | ||
| + | *Scheitert ClamAV (`CLAM_VIRUS_FAIL`), verzichtet Rspamd auf den Virencheck und lässt die E-Mail durch. | ||
| + | *Um dies anzupassen, kann die Datei `force_actions.conf` genutzt werden: | ||
| + | *cat /etc/rspamd/local.d/force_actions.conf | ||
| + | |||
| + | |||
| + | <pre> | ||
| + | rules { | ||
| + | VIRUS_SCANNER_FAIL_EXC { | ||
| + | action = "soft reject"; | ||
| + | expression = "CLAM_VIRUS_FAIL"; | ||
| + | message = "Tempfail - internal scan engine error. (support-id: ${queueid})"; | ||
| + | honor_action = ["reject"]; | ||
| + | } | ||
| + | |||
| + | VIRUS_REJECT { | ||
| + | action = "reject"; | ||
| + | expression = "CLAM_VIRUS"; | ||
| + | message = "REJECT - Virus found (support-id: ${queueid})"; | ||
| + | } | ||
| + | |||
| + | VIRUS_REJECT_MACRO { | ||
| + | action = "reject"; | ||
| + | expression = "CLAM_VIRUS_MACRO"; | ||
| + | message = "REJECT - attachment with macro found (support-id: ${queueid})"; | ||
| + | } | ||
| + | |||
| + | # Keine Ablehnung bei verschlüsselten Archiven/Attachments | ||
| + | VIRUS_REJECT_ENCRYPTED { | ||
| + | # action = "reject"; | ||
| + | expression = "CLAM_VIRUS_ENCRYPTED"; | ||
| + | message = "REJECT - encrypted attachment found (support-id: ${queueid})"; | ||
| + | } | ||
| + | } | ||
</pre> | </pre> | ||
Version vom 20. März 2025, 16:02 Uhr
Rspamd und ClamAV installieren
Debian/Ubuntu
- apt install rspamd clamav-daemon clamav-freshclam redis
RHEL/CentOS
- dnf install rspamd clamav clamav-update redis
Enablen und Startend er Dienste
- systemctl enable rspamd --now
- systemctl enable clamav-daemon --now
- systemctl start redis
- systemctl enable redis.service
Läuft alles
- systemctl status rspamd
- systemctl status clamav-daemon
- systemctl status redis
Dienste und Ports von Rspamd
Rspamd Proxy
- Der Rspamd Proxy dient als Eingangsfilter für E-Mails und leitet sie an die entsprechenden Worker weiter, um die Last zu verteilen.
Port: 11332/tcp (Standardport für Proxy-Dienste)
Rspamd Worker
- Der Rspamd Worker führt die eigentliche Spam-Analyse durch und verarbeitet eingehende Nachrichten anhand von Regeln, Statistiken und externen Diensten.
Port: 11333/tcp (Standardport für Worker-Dienste)
Rspamd Controller
- Der Rspamd Controller stellt eine API für Konfiguration, Statistiken und manuelles Training des Filters zur Verfügung.
Port: 11334/tcp (Standardport für den Controller)
Passwort für den Rspamd Controller und Port nach aussen öffen
- Passwort erzeugen
- rspamadm pw
Enter passphrase: $2$mqbbp8yb4fz8febgpxk7rb4db9p5njwg$xior3gxjbuc76bhsq4rapq7x98cssrm9qkr49kwapgdsahmpzjny
- In der Worker Datei eintragen
- Port an allen Interfaces lauschen lassen
- cat /etc/rspamd/override.d/worker-controller.inc
password = "$2$mqbbp8yb4fz8febgpxk7rb4db9p5njwg$xior3gxjbuc76bhsq4rapq7x98cssrm9qkr49kwapgdsahmpzjny"; bind_socket ="*:11334";
Restart
- systemctl restart rspamd
Zugriff auf das Webinterface
Milters
- Milters sind Mail-Filter, die über das Milter-Protokoll mit MTA-Software wie Postfix oder Sendmail kommunizieren.
- Sie ermöglichen die Verarbeitung und Filterung von E-Mails in Echtzeit, bevor sie zugestellt werden.
- Milter werden häufig für Spam-Filterung, Virenscans und Inhaltsüberprüfungen eingesetzt.
Einbinden in Postfix
- postconf -e "smtpd_milters=inet:127.0.0.1:11332"
- postconf -e "non_smtpd_milters=inet:127.0.0.1:11332"
- postfix reload
Gtube Testmail
- echo 'XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X' | mail -s "Boese Mail" martha
Resultat
Die Logs
- journalctl -u postfix@-.service | grep cleanup
Mar 18 19:21:22 mail.it113.int postfix/cleanup[7407]: 88BDDE0792: milter-reject: END-OF-MESSAGE from localhost[127.0.0.1]: 5.7.1 Gtube pattern; from=<root@mail.it113.int> to=<martha@mail.it113.int> Mar 18 19:21:22 mail.it113.int postfix/cleanup[7407]: 88BDDE0792: to=<martha@mail.it113.int>, orig_to=<martha>, relay=none, delay=0.19, delays=0.19/0/0/0, dsn=5.7.1, status=bounced (Gtube pattern) Mar 18 19:21:22 mail.it113.int postfix/cleanup[7410]: B3D24E07C2: message-id=<20250318182122.B3D24E07C2@mail.it113.int>
Restart
- systemctl restart rspamd
RBL-Integration in Rspamd und Postfix (Proof of Concept)
Rspamd mit lokaler RBL
Configuration
- vi /etc/rspamd/local.d/multimap.conf
blacklist_ip {
type = "ip";
map = "/etc/rspamd/local.d/local_rbl.txt";
symbol = "LOCAL_RBL_HIT";
action = "reject";
description = "Lokale RBL-Hit";
}
Blackliste
- echo 10.88.113.21 > /etc/rspamd/local.d/local_rbl.txt
Rspamd neustarten
- systemctl restart rspamd
Tests
- postiv
- echo hallo welt | rspamc -i 10.88.113.22
Results for file: stdin (0 seconds) [Metric: default] Action: add header Spam: true Score: 7.90 / 15.00 Symbol: ARC_NA (0.00) Symbol: MIME_GOOD (-0.10)[text/plain] Symbol: MIME_TRACE (0.00)[0:+] Symbol: MISSING_DATE (1.00) Symbol: MISSING_FROM (2.00) Symbol: MISSING_MID (2.50) Symbol: MISSING_SUBJECT (0.50) Symbol: MISSING_TO (2.00) Symbol: RCVD_COUNT_ZERO (0.00)[0] Message-ID: undef
- negativ
- echo hallo welt | rspamc -i 10.88.113.21
Results for file: stdin (0 seconds) [Metric: default] Action: reject Spam: true Score: -0.10 / 15.00 Symbol: ARC_NA (0.00) Symbol: LOCAL_RBL_HIT (0.00)[10.88.113.21] Symbol: MIME_GOOD (-0.10)[text/plain] Symbol: MIME_TRACE (0.00)[0:+] Message-ID: undef Message - smtp_message: Matched map: LOCAL_RBL_HIT
Clamav einbinden
- cat /etc/rspamd/local.d/antivirus.conf
clamav {
servers = "127.0.0.1:3310"
#Unix Socket
#servers = "/run/clamav/clamd.ctl"
}
Aktivierung von ClamAV in Rspamd Muss noch getestet werden
Rspamd muss angewiesen werden, ClamAV für Virenprüfungen zu nutzen. Dazu wird die Datei `local.d/antivirus.conf` bearbeitet:
vi /etc/rspamd/local.d/antivirus.conf
Konfiguration für ClamAV:
clamav {
servers = "127.0.0.1:3310";
# Oder alternativ via UNIX-Socket:
# servers = "/run/clamav/clamd.ctl";
}
Reaktionen auf ClamAV-Ergebnisse anpassen
- Falls ClamAV ein Makro (`CLAM_VIRUS_MACRO`) oder ein verschlüsseltes Attachment (`CLAM_VIRUS_ENCRYPTED`) erkennt, wird standardmäßig keine Ablehnung durchgeführt.
- Scheitert ClamAV (`CLAM_VIRUS_FAIL`), verzichtet Rspamd auf den Virencheck und lässt die E-Mail durch.
- Um dies anzupassen, kann die Datei `force_actions.conf` genutzt werden:
- cat /etc/rspamd/local.d/force_actions.conf
rules {
VIRUS_SCANNER_FAIL_EXC {
action = "soft reject";
expression = "CLAM_VIRUS_FAIL";
message = "Tempfail - internal scan engine error. (support-id: ${queueid})";
honor_action = ["reject"];
}
VIRUS_REJECT {
action = "reject";
expression = "CLAM_VIRUS";
message = "REJECT - Virus found (support-id: ${queueid})";
}
VIRUS_REJECT_MACRO {
action = "reject";
expression = "CLAM_VIRUS_MACRO";
message = "REJECT - attachment with macro found (support-id: ${queueid})";
}
# Keine Ablehnung bei verschlüsselten Archiven/Attachments
VIRUS_REJECT_ENCRYPTED {
# action = "reject";
expression = "CLAM_VIRUS_ENCRYPTED";
message = "REJECT - encrypted attachment found (support-id: ${queueid})";
}
}

