Hier werden die Unterschiede zwischen zwei Versionen gezeigt.
| Beide Seiten, vorherige Überarbeitung Vorherige Überarbeitung Nächste Überarbeitung | Vorherige Überarbeitung | ||
|
fortgeschrittene:postfix-rspamd [2024/08/09 08:28] ingo_wichmann |
fortgeschrittene:postfix-rspamd [2025/08/31 12:06] (aktuell) ingo_wichmann [DKIM & DMARC] |
||
|---|---|---|---|
| Zeile 1: | Zeile 1: | ||
| + | ====== rspamd ====== | ||
| + | ===== Doku ===== | ||
| + | https://rspamd.com/doc/tutorials/quickstart.html | ||
| + | |||
| + | ===== Voraussetzung ===== | ||
| + | * [[postfix]] | ||
| + | * [[dovecot-imapd]] | ||
| + | * [[valkey]] oder [[redis]] lokal ereichbar | ||
| + | |||
| + | ==== redis ==== | ||
| + | <file txt /etc/redis/redis.conf> | ||
| + | … | ||
| + | bind 127.0.0.1 ::1 | ||
| + | … | ||
| + | maxmemory 500mb | ||
| + | … | ||
| + | maxmemory-policy volatile-ttl | ||
| + | … | ||
| + | </file> | ||
| + | |||
| + | systemctl restart redis.service | ||
| + | |||
| + | ===== Installation ===== | ||
| + | Paket installieren: | ||
| apt install rspamd | apt install rspamd | ||
| + | Übersicht Konfiguration: | ||
| + | rspamadm configgraph | ||
| + | |||
| + | Konfiguration ausgeben: | ||
| + | rspamadm configdump | ||
| + | |||
| + | Auf welchen Ports lauscht rspamd? | ||
| + | lsof -ac rspamd -Pni -sTCP:LISTEN | ||
| + | |||
| + | Logs: | ||
| + | tail /var/log/rspamd/rspamd.log | ||
| + | |||
| + | ===== redis ===== | ||
| + | rspamadm configwizard checks redis | ||
| + | -> erzeugt:<file txt /etc/rspamd/local.d/redis.conf> | ||
| + | write_servers = "localhost"; | ||
| + | read_servers = "localhost"; | ||
| + | </file> | ||
| + | |||
| + | ===== Postfix ===== | ||
| postconf -e 'smtpd_milters = inet:localhost:11332' | postconf -e 'smtpd_milters = inet:localhost:11332' | ||
| postconf -e 'milter_default_action = accept' | postconf -e 'milter_default_action = accept' | ||
| + | ==== testen ==== | ||
| + | Spricht postfix mit rspamd? | ||
| + | tcpdump -A -i lo tcp port 11332 | ||
| + | |||
| + | Änderungen am Header loggen: | ||
| + | <file txt /etc/postfix/milter_header_checks> | ||
| + | /(.+)/ WARN $1 | ||
| + | </file> | ||
| + | postconf -e 'milter_header_checks = regexp:/etc/postfix/milter_header_checks' | ||
| + | Spam-Mail schicken, dann im Log schauen: | ||
| journalctl -f --facility=mail | journalctl -f --facility=mail | ||
| - | + | -> ''milter-header-warning'' | |
| - | tail -f /var/log/rspamd/* | + | |
| - | tcpdump -A -i lo tcp port 11332 | + | milter_header_checks in Produktion wieder aus machen: |
| + | postconf -# milter_header_checks | ||
| - | /var/lib/rspamd/dkim/$domain.$selector.key | + | === Spam-Test Mail schicken === |
| + | <file txt GTUBE> | ||
| + | This is the GTUBE, the | ||
| + | Generic | ||
| + | Test for | ||
| + | Unsolicited | ||
| + | Bulk | ||
| + | |||
| - | DKIM: | + | If your spam filter supports it, the GTUBE provides a test by which you |
| - | https://rspamd.com/doc/modules/dkim_signing.html | + | can verify that the filter is installed correctly and is detecting incoming |
| + | spam. You can send yourself a test mail containing the following string of | ||
| + | characters (in upper case and with no white spaces and line breaks): | ||
| + | |||
| + | XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X | ||
| + | |||
| + | You should send this test mail from an account outside of your network. | ||
| + | </file> | ||
| + | |||
| + | swaks -f test@example.com -t ingo@iw-1.lxht.de --body @GTUBE | ||
| + | ===== rspamd controller & WebUI ===== | ||
| + | rspamadm configwizard checks controller | ||
| + | -> erzeugt: ''/etc/rspamd/local.d/worker-controller.inc'' | ||
| + | |||
| + | Zugriff auf WebUI: | ||
| + | ssh -L 11334:127.0.0.1:11334 admin@example.com | ||
| + | -> http://localhost:11334/ | ||
| + | |||
| + | ===== DKIM & DMARC ===== | ||
| + | Doku: https://rspamd.com/doc/modules/dkim_signing.html | ||
| + | |||
| + | rspamadm configwizard checks dkim | ||
| + | |||
| + | * DKIM-Selector z.B. ''dkim2025'' | ||
| + | * "//Use domain from authenticated user for sign//" wählen | ||
| + | |||
| + | chown _rspamd /var/lib/rspamd/dkim/example.com.dkim2025.key | ||
| + | |||
| + | Public-Key für RR aus Key erzeugen: | ||
| + | openssl ec -in /var/lib/rspamd/dkim/example.com.dkim2025.key -pubout -outform der | openssl base64 -A | fold -w 200 | while read chunk; do echo "\"$chunk\""; done | ||
| + | |||
| + | * RR in [[bind]] zone eintragen: ''dkim2025._domainkey.example.com. TXT "v=DKIM1; k=rsa; p=" "MII..."'' | ||
| + | * DMARC RR in [[bind]] zone eintragen: ''_dmarc.example.com TXT "v=DMARC1; p=none; rua=mailto:user1@example.com"'' | ||
| + | |||
| + | Konfiguration prüfen: | ||
| + | dig +short dkim2025._domainkey.example.com TXT | ||
| + | dig +short _dmarc.example.com TXT | ||
| + | rspamadm configdump dkim_signing | ||
| + | |||
| + | Dienst neu laden: | ||
| + | systemctl reload rspamd.service | ||
| + | |||
| + | ++++ Statt dessen mit ed25519 Key | | ||
| selector=dkim2024 | selector=dkim2024 | ||
| Zeile 23: | Zeile 126: | ||
| path = "/var/lib/rspamd/dkims/$domain.$selector" | path = "/var/lib/rspamd/dkims/$domain.$selector" | ||
| </file> | </file> | ||
| + | ++++ | ||
| + | |||
| + | ++++ dmarc Reports | | ||
| + | mit | ||
| + | redis-cli KEYS '*' | grep dmarc_rpt | ||
| + | kann man nachschauen, ob rspamd schon Berichte für andere Domains hat. In der letzten Spalte steht das Datum, an dem der Eintrag erzeugt wurde, z.B. 20250412 | ||
| + | Mit | ||
| + | redis-cli ZRANGE "dmarc_rpt;lxht.de;mailto:tuxilio@tuxi.lxht.de;20250412" 0 -1 | ||
| + | kann man sich die Werte anschauen, die beim nächsten Bericht an eine Domain verschickt werden. | ||
| + | Mit | ||
| + | rspamadm dmarc_report -n -v 20250412 | ||
| + | kann man sehe, wie rspamd die reports verarbeiten würde. | ||
| + | rspamadm dmarc_report | ||
| + | muss dann ein Mal täglich von cron oder systemd-timer gestartet werden. | ||
| + | ++++ | ||