Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Beide Seiten der vorigen Revision Vorhergehende Überarbeitung Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
centos:mail_c7:spam_2 [05.11.2014 15:52. ] – django | centos:mail_c7:spam_2 [18.11.2024 19:13. ] (aktuell) – Externe Bearbeitung 127.0.0.1 | ||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
====== erweiterte gewichtete Prüfungen mittels policyd-weight ====== | ====== erweiterte gewichtete Prüfungen mittels policyd-weight ====== | ||
+ | {{: | ||
+ | Policyd-weight nimmt vereinfacht und zusammengefasst folgende Prüfungen vor: | ||
+ | - Passt der Hostname der beim **HELO** übertragen wurde, zu IP-Adresse und verweist seinerseits die IP-Adresse bei einer DNS reverse-Abfrage auf diesen Hostnamen. | ||
+ | - Steht die IP-Adresse des einliefernden Hosts auf mehreren Sperrlisten? | ||
+ | Wird bei der Prüfung durch das komplexe Regelwerk festgestellt, | ||
+ | ===== Installation ===== | ||
+ | ==== via yum ==== | ||
+ | Die einfachste und schnellste Variante bei der Installation ist die aus dem Repository **[[centos: | ||
+ | # yum install policyd-weight | ||
+ | Was das RPM alle mitbrachte zeigt ein Blick in die RPM-Datenbank. | ||
+ | # rpm -qil policyd-weight | ||
+ | < | ||
+ | Version | ||
+ | Release | ||
+ | Architecture: | ||
+ | Install Date: Wed 05 Nov 2014 04:46:20 PM CET | ||
+ | Group : System Environment/ | ||
+ | Size : 132070 | ||
+ | License | ||
+ | Signature | ||
+ | Source RPM : policyd-weight-0.1.15-2beta.el7.centos.src.rpm | ||
+ | Build Date : Wed 05 Nov 2014 04:40:10 PM CET | ||
+ | Build Host : vml000200.dmz.nausch.org | ||
+ | Relocations : (not relocatable) | ||
+ | Packager | ||
+ | Vendor | ||
+ | URL : http:// | ||
+ | Summary | ||
+ | Description : | ||
+ | policyd-weight is a Perl policy daemon for the Postfix MTA (2.1 and later) | ||
+ | intended to eliminate forged envelope senders and HELOs (i.e. in bogus mails). | ||
+ | It allows you to score DNSBLs (RBL/ | ||
+ | addresses before any queuing is done. It allows you to REJECT messages which | ||
+ | have a score higher than allowed, providing improved blocking of spam and | ||
+ | virus mails. policyd-weight caches the most frequent client/ | ||
+ | combinations (SPAM as well as HAM) to reduce the number of DNS queries. | ||
+ | After the first three SMTP commands (HELO, MAIL FROM: and RCPT TO:) the | ||
+ | client' | ||
+ | DNSBLs can be checked, verified and scored. If the client tries to forge | ||
+ | headers or supplies non-existent DNS or bogus data the spam score will | ||
+ | increase, even more so if the client is listed in one or more DNSBLs. Such | ||
+ | mails can be rejected while in transfer, before the mail body is received by | ||
+ | your MTA. This is different from SpamAssassin or amavisd-new: | ||
+ | filtering with these programs, mail needs to be accepted and queued, bandwidth | ||
+ | is used, CPU-time is wasted and mail cannot be rejected without creating a | ||
+ | bounce. Please have a look at the graphical working scheme. | ||
- | # systemctl start policyd-weight | + | Postfix' |
+ | hit, and the mail gets rejected. | ||
+ | MX users get through if their MTA is setup properly, even if their ISP net is | ||
+ | DUL-listed), | ||
+ | on multiple factors. | ||
- | # systemctl status policyd-weight | + | Of course you should still have SpamAssassin and Clamav running (especially |
- | < | + | if you are responsible for a company' |
- | Loaded: loaded (/usr/ | + | will have a lot less to do and thus decrease the need for bandwidth |
- | Active: active (running) since Wed 2014-11-05 16:46:56 CET; 8s ago | + | cycles. Also you might not need greylisting (which would make sense for users |
- | Process: 6315 ExecStart=/ | + | that receive a lot of new spam, though), SPF, extraordinary whitelists or SQL |
- | Main PID: 6316 (policyd-weight ) | + | and other DBs anymore. |
- | | + | /etc/ |
- | | + | / |
- | | + | /usr/lib/systemd/system/ |
- | + | ||
- | Nov 05 16:46:56 vml000087.dmz.nausch.org | + | |
- | Nov 05 16:46:56 vml000087.dmz.nausch.org postfix/policyd-weight[6316]: | + | |
- | Nov 05 16:46:56 vml000087.dmz.nausch.org postfix/ | + | |
- | Nov 05 16:46:56 vml000087.dmz.nausch.org postfix/ | + | |
- | Hint: Some lines were ellipsized, use -l to show in full. | + | |
</ | </ | ||
- | # less / | + | Als nächstes schreiten wir direkt zur **[[centos:mail_c7:spam_2?&# |
- | < | + | |
- | Nov 5 16:46:56 vml000087 postfix/ | + | |
- | Nov 5 16:46:56 vml000087 postfix/ | + | |
- | </ | + | |
+ | ==== manuell ==== | ||
+ | Will oder kann man nicht auf das Repository **[[centos: | ||
- | # netstat | + | Wir holen uns also als erstes das besagte Perl-Script in der aktuellen Version von der [[http://www.policyd-weight.org/|Projektseite]]. |
- | < | + | # wget http://www.policyd-weight.org/policyd-weight |
- | Proto Recv-Q Send-Q Local Address | + | |
- | tcp 0 0 0.0.0.0:25 0.0.0.0: | + | |
- | tcp 0 0 0.0.0.0: | + | |
- | tcp 0 0 127.0.0.1: | + | |
- | tcp 0 0 0.0.0.0: | + | |
- | tcp 0 0 0.0.0.0: | + | |
- | tcp6 | + | |
- | tcp6 | + | |
- | tcp6 | + | |
- | tcp6 | + | |
- | udp 0 0 0.0.0.0: | + | |
- | udp 0 0 0.0.0.0: | + | |
- | udp 0 0 0.0.0.0: | + | |
- | udp 0 0 127.0.0.1: | + | |
- | </ | + | |
- | # lsof -i:12525 | + | |
- | | + | Als nächstes passen wir die Dateirechte an, so dass das Script ausgeführte werden kann. |
- | | + | # chmod u+rx policyd-weight |
+ | Zum Schluß verschieben wir das script noch an Ort und Stelle unter **/ | ||
+ | # mv policyd-weight / | ||
+ | <WRAP round tip>Das vom daemon benötigte Perl-Paket **perl-Net-IP** installieren wir noch mit Hilfe von **yum**.</ | ||
+ | |||
+ | === Programmcheck === | ||
+ | Als erstes überprüfen wir, ob sich das Perl-Script ausführen lässt. Hierzu fragen wir den Versionsstand des Scripts ab. | ||
+ | # policyd-weight -v | ||
+ | | ||
+ | Perl version: | ||
+ | | ||
+ | | ||
+ | === Konfigurationsdatei erzeugen === | ||
+ | Als nächstes erstellen wir uns die Default-Konfigurationsdatei. | ||
+ | # policyd-weight defaults > / | ||
+ | # vim / | ||
+ | <file bash / | ||
+ | # policyd-weight configuration (defaults) Version 0.1.15 beta-2 | ||
+ | # ---------------------------------------------------------------- | ||
+ | | ||
+ | | ||
+ | |||
+ | | ||
+ | # REJECTLEVEL will be rejected | ||
+ | |||
+ | | ||
+ | # A space separated case-sensitive list of | ||
+ | # strings on which if found in the $RET | ||
+ | # logging-string policyd-weight changes | ||
+ | # its action to $DEFER_ACTION in case | ||
+ | # of rejects. | ||
+ | # USE WITH CAUTION! | ||
+ | # DEFAULT: " | ||
+ | |||
+ | | ||
+ | # DEFER_IF_REJECT, | ||
+ | # 4xx response codes. See also access(5) | ||
+ | # DEFAULT: 450 | ||
+ | | ||
+ | # scores greater than DEFER_LEVEL will be | ||
+ | # rejected | ||
+ | # DEFAULT: 5 | ||
+ | |||
+ | | ||
+ | |||
+ | | ||
+ | # If ON request that ALL clients are only | ||
+ | # checked against RBLs | ||
+ | |||
+ | | ||
+ | # qr/ | ||
+ | # qr/ | ||
+ | ); # specify a comma-separated list of regexps | ||
+ | # for client hostnames which shall only | ||
+ | # be RBL checked. This does not work for | ||
+ | # postfix' | ||
+ | # The usage of this should not be the norm | ||
+ | # and is a tool for people which like to | ||
+ | # shoot in their own foot. | ||
+ | # DEFAULT: empty | ||
+ | | ||
+ | |||
+ | | ||
+ | # When set to ON it logs only RBLs which | ||
+ | # affect scoring (positive or negative) | ||
+ | | ||
+ | ## DNSBL settings | ||
+ | | ||
+ | # HOST, HIT SCORE, | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | # ' | ||
+ | ' | ||
+ | #' | ||
+ | ); | ||
+ | |||
+ | | ||
+ | # DNSBLS than this var, it gets | ||
+ | # REJECTed immediately | ||
+ | |||
+ | | ||
+ | # DNSBLs is ABOVE this | ||
+ | # level, reject immediately | ||
+ | |||
+ | | ||
+ | |||
+ | ## RHSBL settings | ||
+ | | ||
+ | ' | ||
+ | ' | ||
+ | # ' | ||
+ | # ' | ||
+ | # ' | ||
+ | ); | ||
+ | |||
+ | | ||
+ | # errors | ||
+ | |||
+ | | ||
+ | |||
+ | ## cache stuff | ||
+ | | ||
+ | # trailing slash) | ||
+ | |||
+ | | ||
+ | # daemon. | ||
+ | |||
+ | | ||
+ | # before starting maintenance routines | ||
+ | # NOTE: standard maintenance jobs happen | ||
+ | # regardless of this setting. | ||
+ | |||
+ | | ||
+ | # maintenance jobs: | ||
+ | # checking for config changes | ||
+ | |||
+ | # negative (i.e. SPAM) result cache settings ################################## | ||
+ | |||
+ | | ||
+ | # To this level the cache will be cleaned. | ||
+ | |||
+ | | ||
+ | |||
+ | | ||
+ | |||
+ | | ||
+ | |||
+ | | ||
+ | # to decrease TTL counter | ||
+ | |||
+ | |||
+ | # positve (i.,e. HAM) result cache settings ################################### | ||
+ | |||
+ | | ||
+ | # of entries the cache will be cleaned | ||
+ | |||
+ | | ||
+ | |||
+ | | ||
+ | |||
+ | | ||
+ | # succeed one time the RBL checks again | ||
+ | |||
+ | | ||
+ | # must pass one time the RBL checks again. | ||
+ | # Values must be nonfractal. Accepted | ||
+ | # time-units: s, m, h, d | ||
+ | |||
+ | | ||
+ | # checks in order to be listed as hard-HAM | ||
+ | # After this time the client will pass | ||
+ | # immediately for PTTL within PTIME | ||
+ | |||
+ | |||
+ | ## DNS settings | ||
+ | | ||
+ | |||
+ | | ||
+ | |||
+ | | ||
+ | # in a complete policy query | ||
+ | |||
+ | | ||
+ | |||
+ | | ||
+ | # broken in Net::DNS version 0.51. Works with | ||
+ | # Net::DNS 0.53; DEFAULT: off | ||
+ | |||
+ | | ||
+ | # Normally policyd-weight tries to use a faster | ||
+ | # RBL lookup routine instead of Net::DNS | ||
+ | |||
+ | |||
+ | | ||
+ | # This overrides resolv.conf settings | ||
+ | # Example: $NS = ' | ||
+ | # DEFAULT: empty | ||
+ | |||
+ | |||
+ | | ||
+ | |||
+ | | ||
+ | # to smtpd clients in order to avoid too many | ||
+ | # established connections to one policyd-weight | ||
+ | # child | ||
+ | |||
+ | # scores for checks, WARNING: they may manipulate eachother | ||
+ | # or be factors for other scores. | ||
+ | # HIT score, MISS Score | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | |||
+ | | ||
+ | |||
+ | | ||
+ | # X-policyd-weight: | ||
+ | # DEFAULT: on | ||
+ | |||
+ | |||
+ | | ||
+ | # the weighted check didn't | ||
+ | # return any response (should never | ||
+ | # appear). | ||
+ | |||
+ | |||
+ | |||
+ | # | ||
+ | # Syslogging options for verbose mode and for fatal errors. | ||
+ | # NOTE: comment out the $syslog_socktype line if syslogging does not | ||
+ | # work on your system. | ||
+ | # | ||
+ | |||
+ | | ||
+ | |||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | |||
+ | # | ||
+ | # Process Options | ||
+ | # | ||
+ | | ||
+ | |||
+ | | ||
+ | # DEFAULT: empty, will be initialized as | ||
+ | # $USER | ||
+ | |||
+ | | ||
+ | | ||
+ | |||
+ | | ||
+ | # listens for policy requests from postfix | ||
+ | |||
+ | | ||
+ | # listen for requests. | ||
+ | # You may only list ONE IP here, if you want | ||
+ | # to listen on all IPs you need to say ' | ||
+ | # here. Default is ' | ||
+ | # You need to restart policyd-weight if you | ||
+ | # change this. | ||
+ | |||
+ | | ||
+ | # policyd-weight accepts | ||
+ | # Default: 1024 | ||
+ | |||
+ | |||
+ | | ||
+ | # it dies. | ||
+ | |||
+ | | ||
+ | </ | ||
+ | |||
+ | Hat man Änderungen an der Konfigurationsdatei vorgenommen, | ||
+ | # perl -c / | ||
+ | |||
+ | / | ||
+ | |||
+ | === User polw anlegen === | ||
+ | Für den Betrieb benötigen wir noch einen User **polw**, den wir mit | ||
+ | # useradd -r -s /sbin/false polw | ||
+ | |||
+ | anlegen. | ||
+ | |||
+ | === systemd Startscript anlegen ==== | ||
+ | Zum Starten unseres Daemon legen wir uns noch ein Startscript an. | ||
+ | # vim / | ||
+ | |||
+ | <file bash / | ||
+ | Description=policyd-weight is a Perl policy daemon for the Postfix MTA (2.1 and later) intended to eliminate forged envelope senders and HELOs (i.e. in bogus mails). | ||
+ | Before=postfix.service | ||
+ | After=syslog.target network.target | ||
+ | |||
+ | [Service] | ||
+ | Type=forking | ||
+ | EnvironmentFile=/ | ||
+ | Restart=on-failure | ||
+ | ExecStart=/ | ||
+ | ExecReload=/ | ||
+ | ExecStop=/ | ||
+ | |||
+ | [Install] | ||
+ | WantedBy=multi-user.target | ||
+ | </ | ||
- | ==== Postfix Konfiguration ==== | ||
- | Bei den **smtpd_recipient_restrictions** tragen wir nun zur Aktivierung folgenden Eintrag nach dem greylisting-Eintrag ein. | ||
- | # vim / | ||
- | <code bash> | ||
- | # Greylisting via postgrey checken via Unix-Socket | ||
- | check_policy_service unix: | ||
- | # Policyd-Weight check over TCP-Connection | ||
- | check_client_access btree:/ | ||
- | check_policy_service inet: | ||
- | ... | ||
- | </ | ||
+ | ===== Konfiguration ===== | ||
==== Ausnahmeregelungen für Absendeserver | ==== Ausnahmeregelungen für Absendeserver | ||
- | Leider kommt es auch vor, dass vor allem große Provider hinter ihren MX ein cluster betreiben, die mit wechselnden IP-Adrressen | + | Leider kommt es auch vor, dass vor allem große Provider hinter ihren MX ein cluster betreiben, die mit wechselnden IP-Adressen |
Zeile 105: | Zeile 423: | ||
</ | </ | ||
+ | ==== Postfix Konfiguration ==== | ||
+ | Bei der [[centos: | ||
+ | # vim / | ||
+ | <code bash>... | ||
+ | ################################################################################ | ||
+ | ## SMTP RECIPIENT RESTRICTIONS | ||
+ | # | ||
+ | # Django : 2014-10-29 - Schutz unserer Empfänger mit Hilfe der Recipient | ||
+ | # Restrictions | ||
+ | # default: smtpd_recipient_restrictions = | ||
+ | smtpd_recipient_restrictions = | ||
+ | # Postmaster, abuse und andere aufgaben- oder funktionsgebundene | ||
+ | # eMail-Adressen (Role-Accounts) whitelisten | ||
+ | | ||
+ | # Black- und Whitelisting | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | # Unsere eigenen Nutzer zulassen-/ | ||
+ | # (Kapitel 8.2.2 Relaying erlauben und verbieten) | ||
+ | | ||
+ | | ||
+ | |||
+ | # RBL überprüfen | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | # Greylisting via postgrey checken via Unix-Socket | ||
+ | # (Kapitel 9.2.5 postgrey installieren) | ||
+ | | ||
+ | |||
+ | # Policyd-Weight check over TCP-Connection | ||
+ | # (Kapitel 9.3 policyd-weight installieren) | ||
+ | | ||
+ | | ||
+ | |||
+ | # Dynamische Prüfung auf existente Relay-Empfänger | ||
+ | # (Kapitel 12.2.2 Dynamische Empfänger-Verifizierung) | ||
+ | | ||
+ | |||
+ | # Backupserver (MX) erlauben | ||
+ | | ||
+ | |||
+ | # alles andere an relaying verbieten | ||
+ | # (Kapitel 8.2.2 Relaying erlauben und verbieten) | ||
+ | | ||
+ | |||
+ | # Quota-Status-Policy-Daemon am Dovecot-Backend-System | ||
+ | # Dovecotbuch (ISBN 978-3-95539-74-7) Seite 219 ff. | ||
+ | # (Kapitel 11.11 "Der Quota-Policy-Server für Postfix" | ||
+ | | ||
+ | |||
+ | # Zu guter Letzt alles durchlassen, | ||
+ | # beanstandet wurde | ||
+ | | ||
+ | </ | ||
+ | |||
+ | ===== Programmstart ===== | ||
+ | Das Starten des Daemon erfolgt über folgenden Aufruf. | ||
+ | # systemctl start policyd-weight | ||
+ | |||
+ | Den erfolgreichen Start bzw. den Status des policyd-weight Daemon können wir bei Bedarf mit folgendem Aufruf abfragen. | ||
+ | # systemctl status policyd-weight | ||
+ | < | ||
+ | | ||
+ | | ||
+ | Process: 6315 ExecStart=/ | ||
+ | Main PID: 6316 (policyd-weight ) | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | Nov 05 16:46:56 vml000087.dmz.nausch.org systemd[1]: Started policyd-weight is a Perl policy daemon for the Postfix MTA (2.1 and later) intended to eliminate forged envelope senders and HE...gus mails).. | ||
+ | Nov 05 16:46:56 vml000087.dmz.nausch.org postfix/ | ||
+ | Nov 05 16:46:56 vml000087.dmz.nausch.org postfix/ | ||
+ | Nov 05 16:46:56 vml000087.dmz.nausch.org postfix/ | ||
+ | Hint: Some lines were ellipsized, use -l to show in full. | ||
+ | </ | ||
+ | |||
+ | Im Maillog wird der Start des Daemon entsprechend dokumentiert. | ||
+ | # less / | ||
+ | < | ||
+ | Nov 5 16:46:56 vml000087 postfix/ | ||
+ | Nov 5 16:46:56 vml000087 postfix/ | ||
+ | </ | ||
+ | |||
+ | Mit Hilfe von **netstat** können wir überprüfen, | ||
+ | # netstat -tulpen | ||
+ | < | ||
+ | Proto Recv-Q Send-Q Local Address | ||
+ | tcp 0 0 0.0.0.0: | ||
+ | tcp 0 0 0.0.0.0: | ||
+ | tcp 0 0 127.0.0.1: | ||
+ | tcp 0 0 0.0.0.0: | ||
+ | tcp 0 0 0.0.0.0: | ||
+ | tcp6 | ||
+ | tcp6 | ||
+ | tcp6 | ||
+ | tcp6 | ||
+ | udp 0 0 0.0.0.0: | ||
+ | udp 0 0 0.0.0.0: | ||
+ | udp 0 0 0.0.0.0: | ||
+ | udp 0 0 127.0.0.1: | ||
+ | </ | ||
+ | |||
+ | Gleiches können wir natürlich auch mit dem Befehl **lsof** erreichen. | ||
+ | # lsof -i:12525 | ||
+ | |||
+ | | ||
+ | | ||
+ | Damit der Daemon automatisch beim Hochfahren des Servers gestartet wird, nutzen wir folgenden Aufruf. | ||
+ | # systemctl enable policyd-weight.service | ||
+ | ln -s '/ | ||
+ | Wollen wir überprüfen ob der Dienst automatisch startet, verwenden wir folgenden Aufruf. | ||
+ | # systemctl is-enabled policyd-weight.service | ||
+ | | ||
+ | Die Rückmeldung **enabled** zeigt an, dass der Dienst automatisch startet; ein **disabled** zeigt entsprechend an, dass der Dienst __nicht__ automatisch startet. | ||
===== Bewertungsbeispiele ===== | ===== Bewertungsbeispiele ===== | ||
Zeile 151: | Zeile 589: | ||
- **Daemon starten** < | - **Daemon starten** < | ||
+ | ===== FAZIT ===== | ||
+ | Der Policy-Daemon **policyd-weight** hat sich, wie auch **[[centos: | ||
+ | |||
+ | Da aber der Dienst **rfc-ignorant.org** mittlerweilen den Dienst eingestellt hat und die Gewichtung der unterschiedlichen Gewichtung von **[[http:// | ||
+ | |||
+ | <WRAP center round tip> | ||
+ | **summa sumarum:** | ||
+ | |||
+ | Wie auch schon beim **[[centos: | ||
+ | |||
+ | </ | ||
+ | ====== Links ====== | ||
+ | * **⇐ [[centos: | ||
+ | * **⇒ [[centos: | ||
+ | * **[[centos: | ||
+ | * **[[wiki: | ||
+ | * **[[http:// | ||