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:57. ] – [erweiterte gewichtete Prüfungen mittels policyd-weight] 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: | 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 | + | - Passt der Hostname der beim **HELO** übertragen wurde, zu IP-Adresse und verweist seinerseits die IP-Adresse bei einer DNS reverse-Abfrage auf diesen |
| - | - Steht die IP-Adresse des einliefernden Hosts auf mehreren Sperrlisten? | + | - Steht die IP-Adresse des einliefernden Hosts auf mehreren Sperrlisten? |
| Wird bei der Prüfung durch das komplexe Regelwerk festgestellt, | Wird bei der Prüfung durch das komplexe Regelwerk festgestellt, | ||
| - | ===== INSTALLATION | + | ===== Installation |
| - | + | ==== via yum ==== | |
| + | Die einfachste und schnellste Variante bei der Installation ist die aus dem Repository **[[centos: | ||
| # yum install policyd-weight | # yum install policyd-weight | ||
| + | Was das RPM alle mitbrachte zeigt ein Blick in die RPM-Datenbank. | ||
| # rpm -qil policyd-weight | # rpm -qil policyd-weight | ||
| < | < | ||
| Zeile 69: | Zeile 69: | ||
| </ | </ | ||
| + | Als nächstes schreiten wir direkt zur **[[centos: | ||
| - | # systemctl start policyd-weight | + | ==== manuell ==== |
| + | Will oder kann man nicht auf das Repository **[[centos: | ||
| - | # systemctl status policyd-weight | + | Wir holen uns also als erstes das besagte Perl-Script |
| - | < | + | # wget http://www.policyd-weight.org/ |
| - | | + | |
| - | Active: active (running) since Wed 2014-11-05 16:46:56 CET; 8s ago | + | |
| - | Process: 6315 ExecStart=/usr/bin/ | + | |
| - | 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).. | + | Als nächstes passen wir die Dateirechte an, so dass das Script ausgeführte werden kann. |
| - | Nov 05 16:46:56 vml000087.dmz.nausch.org postfix/policyd-weight[6316]: policyd-weight 0.1.15 beta-2 started and daemonized. conf:/ | + | # chmod u+rx policyd-weight |
| - | 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 /var/log/maillog | + | Zum Schluß verschieben wir das script noch an Ort und Stelle unter **/usr/local/bin**. |
| - | < | + | # mv policyd-weight /usr/local/bin/ |
| - | Nov 5 16:46:56 vml000087 postfix/policyd-weight[6316]: | + | |
| - | Nov 5 16:46:56 vml000087 postfix/ | + | |
| - | </code> | + | |
| + | <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 | ||
| - | # netstat | + | policyd-weight version: 0.1.15 beta-2, CacheVer: 5 |
| - | < | + | Perl version: 5.010001 |
| - | Proto Recv-Q Send-Q Local Address | + | Net::DNS version: 0.65 |
| - | tcp 0 0 0.0.0.0:25 0.0.0.0: | + | OS: Linux 2.6.32-220.17.1.el6.x86_64 |
| - | tcp 0 0 0.0.0.0: | + | |
| - | tcp 0 0 127.0.0.1: | + | |
| - | tcp 0 0 0.0.0.0:465 | + | |
| - | tcp 0 0 0.0.0.0:22 0.0.0.0: | + | |
| - | tcp6 | + | |
| - | tcp6 | + | |
| - | tcp6 | + | |
| - | tcp6 | + | |
| - | udp 0 0 0.0.0.0: | + | |
| - | udp 0 0 0.0.0.0:46503 0.0.0.0:* | + | |
| - | udp 0 0 0.0.0.0: | + | |
| - | udp 0 0 127.0.0.1:323 0.0.0.0:* | + | |
| - | </ | + | |
| - | # lsof -i:12525 | + | |
| - | | + | === Konfigurationsdatei erzeugen === |
| - | | + | Als nächstes erstellen wir uns die Default-Konfigurationsdatei. |
| + | # policyd-weight defaults > /etc/policyd-weight.conf | ||
| + | # 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, | ||
| + | ' | ||
| + | ' | ||
| + | ' | ||
| + | # ' | ||
| + | ' | ||
| + | #' | ||
| + | ); | ||
| - | ==== Postfix Konfiguration ==== | + | |
| - | Bei den **smtpd_recipient_restrictions** tragen wir nun zur Aktivierung folgenden Eintrag nach dem greylisting-Eintrag ein. | + | # DNSBLS than this var, it gets |
| - | # vim / | + | # REJECTed immediately |
| - | <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: | + | |
| - | ... | + | |
| - | </ | + | |
| + | | ||
| + | # 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 | ||
| + | </ | ||
| + | |||
| + | |||
| + | ===== 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 169: | 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 215: | 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:// | ||