Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

Beide Seiten der vorigen Revision Vorhergehende Überarbeitung
Nächste Überarbeitung
Vorhergehende Überarbeitung
centos:mail_c7:spam_2 [05.11.2014 15:52. ] djangocentos:mail_c7:spam_2 [22.07.2019 15:02. ] (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 ======
 +{{:centos:mail_c7:postfix-spam.png?nolink&125 |Bild: Symbolbild Postfix und SPAM}} Das zweite (wesentliche) Standbein bei unserer SPAM- und Schadcode-Prüfung von eMails kann der Policy-Dämon [[http://www.policyd-weight.org/|policyd-weight]] von [[http://selling-it.de|Robert Felber]]. Postfix leitet alle Client-Angaben bei der Einlieferung an den Policy-Daemon während des SMTP-Dialogs weiter, der dann eine Plausibilitätsprüfung vornimmt. Fälscht ein SPAMer den **HELO** Namen bzw. die Absenderangaben beim **MAIL FROM**, so wird dies ebenso bei der gewichteten Prüfung negativ bewertet, die das Vorhandensein, der Client-IP-Adresse auf einer oder mehreren RBLs. 
  
 +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? Dabei unterscheidet der Policy-Daemon zwischen einzelnen RBLs und vergibt entsprechend negative Punkte, sofern die IP-Adresse gelistet ist aber auch positive Punkte, wenn die IP-Adresse eben nicht gelistet ist. 
  
 +Wird bei der Prüfung durch das komplexe Regelwerk festgestellt, dass Kombinationen aus den oben genannten Punkten zu negativ aufgefallen sind, dann wird die weitere Bearbeitung beendet und die Annahme der eMail mit einem **500**er Fehler-Code final abgewiesen.
  
 +===== Installation =====
 +==== via yum ====
 +Die einfachste und schnellste Variante bei der Installation ist die aus dem Repository **[[centos:mailserver.guru|mailserver.guru]]**. Hier reicht ein einfacher Aufruf von **yum** und alles wird automatisch installiert inkl. der Paketabhängigkeiten. Will man nicht diesen weg beschreiten, steht immer noch der [[centos:mail_c7:spam_2?&#manuell|manuelle Weg]] offen.
 +   # yum install policyd-weight 
  
 +Was das RPM alle mitbrachte zeigt ein Blick in die RPM-Datenbank.
 +   # rpm -qil policyd-weight
 +<code>Name        : policyd-weight
 +Version     : 0.1.15
 +Release     : 2beta.el7.centos
 +Architecture: noarch
 +Install Date: Wed 05 Nov 2014 04:46:20 PM CET
 +Group       : System Environment/Daemons
 +Size        : 132070
 +License     : Robert Felber. All rights reserved.
 +Signature   : RSA/SHA1, Wed 05 Nov 2014 04:40:20 PM CET, Key ID 60ecfb9e8195aea0
 +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    : Django <django@nausch.org>
 +Vendor      : EDV Beratung Selling-IT - Robert Felber
 +URL         : http://www.policyd-weight.org/
 +Summary     : Policy Daemon for the Postfix MTA
 +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/RHSBL), HELO, MAIL FROM and client IP
 +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/sender
 +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's IP address, corresponding DNS records (A, MX and PTR) and multiple
 +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: for scoring or
 +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' built-in checks can be too tough for poorly configured clients: one 
 +hit, and the mail gets rejected. policyd-weight is designed to be fair (DynDNS 
 +MX users get through if their MTA is setup properly, even if their ISP net is 
 +DUL-listed), because its decision whether to reject or accept a mail is based 
 +on multiple factors.
  
-   # systemctl status policyd-weight +Of course you should still have SpamAssassin and Clamav running (especially 
-<code>policyd-weight.service - policyd-weight is Perl policy daemon for the Postfix MTA (2.1 and laterintended to eliminate forged envelope senders and HELOs (i.e. in bogus mails). +if you are responsible for company's security and data). But these programs 
-   Loaded: loaded (/usr/lib/systemd/system/policyd-weight.service; disabled) +will have a lot less to do and thus decrease the need for bandwidth and CPU 
-   Active: active (running) since Wed 2014-11-05 16:46:56 CET; 8s ago +cyclesAlso you might not need greylisting (which would make sense for users 
-  Process: 6315 ExecStart=/usr/bin/policyd-weight start (code=exited, status=0/SUCCESS) +that receive a lot of new spam, though), SPF, extraordinary whitelists or SQL 
- Main PID: 6316 (policyd-weight ) +and other DBs anymore
-   CGroup: /system.slice/policyd-weight.service +/etc/policyd-weight.conf 
-           ├─6316 policyd-weight (master) +/usr/bin/policyd-weight 
-           └─6317 policyd-weight (cache) +/usr/lib/systemd/system/policyd-weight.service
- +
-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/policyd-weight[6316]: policyd-weight 0.1.15 beta-2 started and daemonized. conf:/etc/policyd-weight.conf; GID:995 995 EGID:995 995 UID:995 E...int mode: 0 +
-Nov 05 16:46:56 vml000087.dmz.nausch.org postfix/policyd-weight[6316]: cache_query: start: calling spawn_cache() +
-Nov 05 16:46:56 vml000087.dmz.nausch.org postfix/policyd-weight[6317]: cache spawned +
-Hint: Some lines were ellipsized, use -l to show in full.+
 </code> </code>
  
-   # less /var/log/maillog +Als nächstes schreiten wir direkt zur **[[centos:mail_c7:spam_2?&#konfiguration|Konfiguration]]**; d.hwie überspringen das Kapitel "manuelle Installation".
-<code>Nov  5 16:46:56 vml000087 postfix/policyd-weight[6316]: policyd-weight 0.1.15 beta-2 started and daemonizedconf:/etc/policyd-weight.conf; GID:995 995 EGID:995 995 UID:995 EUID:995; taint mode: 0 +
-Nov  5 16:46:56 vml000087 postfix/policyd-weight[6316]: cache_query: start: calling spawn_cache() +
-Nov  5 16:46:56 vml000087 postfix/policyd-weight[6317]: cache spawned +
-</code>+
  
 +==== manuell ====
 +Will oder kann man nicht auf das Repository **[[centos:mailserver.guru|mailserver.guru]]** zurückgreifen, steht immer noch der Installation per Hand nichts im Wege.
  
-   # netstat -tulpen +Wir holen uns also als erstes das besagte Perl-Script in der aktuellen Version von der [[http://www.policyd-weight.org/|Projektseite]].  
-<code>Active Internet connections (only servers) +   # wget http://www.policyd-weight.org/policyd-weight
-Proto Recv-Q Send-Q Local Address           Foreign Address         State       User       Inode      PID/Program name     +
-tcp        0      0 0.0.0.0:25              0.0.0.0:              LISTEN      0          56505      4931/master          +
-tcp        0      0 0.0.0.0:587             0.0.0.0:              LISTEN      0          56511      4931/master          +
-tcp        0      0 127.0.0.1:12525         0.0.0.0:              LISTEN      0          67780      6316/policyd-weight  +
-tcp        0      0 0.0.0.0:465             0.0.0.0:              LISTEN      0          56517      4931/master          +
-tcp        0      0 0.0.0.0:22              0.0.0.0:              LISTEN      0          24989      1223/sshd            +
-tcp6            0 :::25                   :::                   LISTEN      0          56506      4931/master          +
-tcp6            0 :::587                  :::*                    LISTEN      0          56512      4931/master          +
-tcp6            0 :::465                  :::*                    LISTEN      0          56518      4931/master          +
-tcp6            0 :::22                   :::                   LISTEN      0          24991      1223/sshd            +
-udp        0      0 0.0.0.0:50558           0.0.0.0:                          70         21030      571/avahi-daemon: r  +
-udp        0      0 0.0.0.0:46503           0.0.0.0:                                   20919      594/chronyd          +
-udp        0      0 0.0.0.0:5353            0.0.0.0:                          70         21029      571/avahi-daemon: r  +
-udp        0      0 127.0.0.1:323           0.0.0.0:                                   20920      594/chronyd          +
-</code> +
-   # lsof -i:12525+
  
-   COMMAND    PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME +Als nächstes passen wir die Dateirechte an, so dass das Script ausgeführte werden kann. 
-   policyd-w 6316 polw    4u  IPv4  67780      0t0  TCP localhost:12525 (LISTEN)+   # chmod u+rx policyd-weight
  
 +Zum Schluß verschieben wir das script noch an Ort und Stelle unter **/usr/local/bin**.  
 +   # mv policyd-weight /usr/local/bin/
  
 +<WRAP round tip>Das vom daemon benötigte Perl-Paket **perl-Net-IP** installieren wir noch mit Hilfe von **yum**.</WRAP>
 +   
 +=== 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
  
 +   policyd-weight version: 0.1.15 beta-2, CacheVer: 5
 +   Perl version:           5.010001
 +   Net::DNS version:       0.65
 +   OS:                     Linux 2.6.32-220.17.1.el6.x86_64
  
 +=== Konfigurationsdatei erzeugen ===
 +Als nächstes erstellen wir uns die Default-Konfigurationsdatei.
 +   # policyd-weight defaults > /etc/policyd-weight.conf
  
  
 +   # vim /etc/policyd-weight.conf
 +<file bash /etc/policyd-weight.conf># ----------------------------------------------------------------
 +#  policyd-weight configuration (defaults) Version 0.1.15 beta-2 
 +# ----------------------------------------------------------------
  
  
 +   $DEBUG        = 0;               # 1 or 0 - don't comment
  
 +   $REJECTMSG    = "550 Mail appeared to be SPAM or forged. Ask your Mail/DNS-Administrator to correct HELO and DNS MX settings or to get removed from DNSBLs";
 +                                                                                                                                                                                 
 +   $REJECTLEVEL  = 1;               # Mails with scores which exceed this                                                                                                        
 +                                    # REJECTLEVEL will be rejected                                                                                                               
 +                                                                                                                                                                                 
 +   $DEFER_STRING = 'IN_SPAMCOP= BOGUS_MX=';                                                                                                                                      
 +                                    # 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: "IN_SPAMCOP= BOGUS_MX="                                                                                                           
 +                                                                                                                                                                                 
  
 +   $DEFER_ACTION = '450';           # Possible values: DEFER_IF_PERMIT,
 +                                    # DEFER_IF_REJECT, 
 +                                    # 4xx response codes. See also access(5)
 +                                    # DEFAULT: 450
  
 +   $DEFER_LEVEL  = 5;               # DEFER mail only up to this level
 +                                    # scores greater than DEFER_LEVEL will be
 +                                    # rejected
 +                                    # DEFAULT: 5
 +
 +   $DNSERRMSG         = '450 No DNS entries for your MTA, HELO and Domain. Contact YOUR administrator';
 +
 +   $dnsbl_checks_only = 0;          # 1: ON, 0: OFF (default)
 +                                    # If ON request that ALL clients are only
 +                                    # checked against RBLs
 +
 +   @dnsbl_checks_only_regexps = (
 +    # qr/[^.]*(exch|smtp|mx|mail).*\..*\../,
 +    # qr/yahoo.com$/
 +);                                  # specify a comma-separated list of regexps
 +                                    # for client hostnames which shall only
 +                                    # be RBL checked. This does not work for
 +                                    # postfix' "unknown" clients.
 +                                    # 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
 +                                    
 +
 +   $LOG_BAD_RBL_ONLY  = 1;          # 1: ON (default), 0: OFF
 +                                    # When set to ON it logs only RBLs which
 +                                    # affect scoring (positive or negative)
 +                                    
 +## DNSBL settings
 +   @dnsbl_score = (
 +#    HOST,                    HIT SCORE,  MISS SCORE,  LOG NAME
 +    'pbl.spamhaus.org',       3.25,          0,        'DYN_PBL_SPAMHAUS',
 +    'sbl-xbl.spamhaus.org',   4.35,       -1.5,        'SBL_XBL_SPAMHAUS',
 +    'bl.spamcop.net',         3.75,       -1.5,        'SPAMCOP',
 +#    'dnsbl.njabl.org',        4.25,       -1.5,        'BL_NJABL',
 +    'ix.dnsbl.manitu.net',    4.35,          0,        'IX_MANITU'
 +    #'rbl.ipv6-world.net',     4.25,          0,        'IPv6_RBL'  #don't use, kept for testing failures!
 +);
 +
 +   $MAXDNSBLHITS  = 2;  # If Client IP is listed in MORE
 +                        # DNSBLS than this var, it gets
 +                        # REJECTed immediately
 +
 +   $MAXDNSBLSCORE = 8;  # alternatively, if the score of
 +                        # DNSBLs is ABOVE this
 +                        # level, reject immediately
 +
 +   $MAXDNSBLMSG   = '550 Your MTA is listed in too many DNSBLs';
 +
 +## RHSBL settings
 +   @rhsbl_score = (
 +    'multi.surbl.org',             4,        0,        'SURBL',
 +    'rhsbl.ahbl.org',              4,        0,        'AHBL',
 +#    'dsn.rfc-ignorant.org',        3.5,      0,        'DSN_RFCI',
 +#    'postmaster.rfc-ignorant.org', 0.1,      0,        'PM_RFCI',
 +#    'abuse.rfc-ignorant.org',      0.1,      0,        'ABUSE_RFCI'
 +);
 +
 +   $BL_ERROR_SKIP     = 2;  # skip a RBL if this RBL had this many continuous
 +                            # errors
 +
 +   $BL_SKIP_RELEASE   = 10; # skip a RBL for that many times
 +
 +## cache stuff
 +   $LOCKPATH          = '/tmp/.policyd-weight/';    # must be a directory (add
 +                                                    # trailing slash)
 +
 +   $SPATH             = $LOCKPATH.'/polw.sock';     # socket path for the cache
 +                                                    # daemon. 
 +
 +   $MAXIDLECACHE      = 60; # how many seconds the cache may be idle
 +                            # before starting maintenance routines
 +                            # NOTE: standard maintenance jobs happen
 +                            # regardless of this setting.
 +
 +   $MAINTENANCE_LEVEL = 5;  # after this number of requests do following
 +                            # maintenance jobs:
 +                            # checking for config changes
 +
 +# negative (i.e. SPAM) result cache settings ##################################
 +
 +   $CACHESIZE       = 2000; # set to 0 to disable caching for spam results. 
 +                            # To this level the cache will be cleaned.
 +
 +   $CACHEMAXSIZE    = 4000; # at this number of entries cleanup takes place
 +
 +   $CACHEREJECTMSG  = '550 temporarily blocked because of previous errors';
 +
 +   $NTTL            = 1;    # after NTTL retries the cache entry is deleted
 +
 +   $NTIME           = 30;   # client MUST NOT retry within this seconds in order
 +                            # to decrease TTL counter
 +
 +
 +# positve (i.,e. HAM) result cache settings ###################################
 +
 +   $POSCACHESIZE    = 1000; # set to 0 to disable caching of HAM. To this number
 +                            # of entries the cache will be cleaned
 +
 +   $POSCACHEMAXSIZE = 2000; # at this number of entries cleanup takes place
 +
 +   $POSCACHEMSG     = 'using cached result';
 +
 +   $PTTL            = 60;   # after PTTL requests the HAM entry must
 +                            # succeed one time the RBL checks again
 +
 +   $PTIME           = '3h'; # after $PTIME in HAM Cache the client
 +                            # must pass one time the RBL checks again.
 +                            # Values must be nonfractal. Accepted
 +                            # time-units: s, m, h, d
 +
 +   $TEMP_PTIME      = '1d'; # The client must pass this time the RBL
 +                            # checks in order to be listed as hard-HAM
 +                            # After this time the client will pass
 +                            # immediately for PTTL within PTIME
 +
 +
 +## DNS settings
 +   $DNS_RETRIES     = 2;    # Retries for ONE DNS-Lookup
 +
 +   $DNS_RETRY_IVAL  = 2;    # Retry-interval for ONE DNS-Lookup
 +
 +   $MAXDNSERR       = 3;    # max error count for unresponded queries
 +                            # in a complete policy query
 +
 +   $MAXDNSERRMSG    = 'passed - too many local DNS-errors';
 +
 +   $PUDP            = 0;    # persistent udp connection for DNS queries.
 +                            # broken in Net::DNS version 0.51. Works with
 +                            # Net::DNS 0.53; DEFAULT: off
 +
 +   $USE_NET_DNS     = 0;    # Force the usage of Net::DNS for RBL lookups.
 +                            # Normally policyd-weight tries to use a faster
 +                            # RBL lookup routine instead of Net::DNS
 +
 +
 +   $NS              = '';   # A list of space separated NS IPs
 +                            # This overrides resolv.conf settings
 +                            # Example: $NS = '1.2.3.4 1.2.3.5';
 +                            # DEFAULT: empty
 +
 +
 +   $IPC_TIMEOUT     = 2;    # timeout for receiving from cache instance
 +
 +   $TRY_BALANCE     = 0;    # If set to 1 policyd-weight closes connections
 +                            # 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
 +   @client_ip_eq_helo_score          = (1.5,       -1.25 );
 +   @helo_score                       = (1.5,       -2    );
 +   @helo_from_mx_eq_ip_score         = (1.5,       -3.1  );
 +   @helo_numeric_score               = (2.5,        0    );
 +   @from_match_regex_verified_helo   = (1,         -2    );
 +   @from_match_regex_unverified_helo = (1.6,       -1.5  );
 +   @from_match_regex_failed_helo     = (2.5,        0    );
 +   @helo_seems_dialup                = (1.5,        0    );
 +   @failed_helo_seems_dialup         = (2,          0    );
 +   @helo_ip_in_client_subnet         = (0,         -1.2  );
 +   @helo_ip_in_cl16_subnet           = (0,         -0.41 );
 +   @client_seems_dialup_score        = (3.75,          );
 +   @from_multiparted                 = (1.09,          );
 +   @from_anon                        = (1.17,          );
 +   @bogus_mx_score                   = (2.1,        0    );
 +   @random_sender_score              = (0.25,          );
 +   @rhsbl_penalty_score              = (3.1,        0    );
 +   @enforce_dyndns_score             = (3,          0    );
 +
 +
 +   $VERBOSE = 0;
 +
 +   $ADD_X_HEADER        = 1;    # Switch on or off an additional 
 +                                # X-policyd-weight: header
 +                                # DEFAULT: on
 +
 +
 +   $DEFAULT_RESPONSE    = 'DUNNO default'; # Fallback response in case
 +                                           # 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.
 +#
 +
 +   $syslog_socktype = 'unix';   # inet, unix, stream, console
 +
 +   $syslog_facility = "mail";
 +   $syslog_options  = "pid";
 +   $syslog_priority = "info";
 +   $syslog_ident    = "postfix/policyd-weight";
 +
 +
 +#
 +# Process Options
 +#
 +   $USER            = "polw";      # User must be a username, no UID
 +
 +   $GROUP           = "";          # specify GROUP if necessary
 +                                   # DEFAULT: empty, will be initialized as 
 +                                   # $USER
 +
 +   $MAX_PROC        = 50;          # Upper limit if child processes
 +   $MIN_PROC        = 3;           # keep that minimum processes alive
 +
 +   $TCP_PORT        = 12525;       # The TCP port on which policyd-weight 
 +                                   # listens for policy requests from postfix
 +
 +   $BIND_ADDRESS    = '127.0.0.1'; # IP-Address on which policyd-weight will
 +                                   # listen for requests.
 +                                   # You may only list ONE IP here, if you want
 +                                   # to listen on all IPs you need to say 'all'
 +                                   # here. Default is '127.0.0.1'.
 +                                   # You need to restart policyd-weight if you
 +                                   # change this.
 +
 +   $SOMAXCONN       = 1024;        # Maximum of client connections 
 +                                   # policyd-weight accepts
 +                                   # Default: 1024
 +                                   
 +
 +   $CHILDIDLE       = 240;         # how many seconds a child may be idle before
 +                                   # it dies.
 +
 +   $PIDFILE         = "/var/run/policyd-weight.pid";
 +</file>
 +
 +Hat man Änderungen an der Konfigurationsdatei vorgenommen, so kann mit mit Hilfe des folgenden Aufrufs einen Syntaxcheck durchführen.
 +   # perl -c /etc/policyd-weight.conf
 +
 +   /etc/policyd-weight.conf syntax OK
 +
 +=== 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 /usr/lib/systemd/system/policyd-weight.service
 +
 +<file bash /usr/lib/systemd/system/policyd-weight.service>[Unit]
 +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=/etc/policyd-weight.conf
 +Restart=on-failure
 +ExecStart=/usr/local/bin/policyd-weight start
 +ExecReload=/usr/local/bin/policyd-weight reload
 +ExecStop=/usr/local/bin/policyd-weight stop
 +
 +[Install]
 +WantedBy=multi-user.target
 +</file>
  
-==== Postfix Konfiguration ==== 
-Bei den **smtpd_recipient_restrictions** tragen wir nun zur Aktivierung folgenden Eintrag nach dem greylisting-Eintrag ein. 
-   # vim /etc/postfix/main.cf 
-<code bash>...    
-# Greylisting via postgrey checken via Unix-Socket      (Kapitel 9.2.5 postgrey installieren) 
-        check_policy_service unix:postgrey/socket, 
-# Policyd-Weight check over TCP-Connection              (Kapitel 9.3 policyd-weight installieren) 
-        check_client_access btree:/etc/postfix/policyd_weight_client_whitelist, 
-        check_policy_service inet:127.0.0.1:12525, 
-... 
-</code> 
  
 +===== 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 aus einem Pool aufschlagen. Damit können unter Umständen Probleme bei der Bewertung entstehen. Diese schalten wir dann bei Bedarf in der **policyd_weight_client_whitelist** frei.+Leider kommt es auch vor, dass vor allem große Provider hinter ihren MX ein cluster betreiben, die mit wechselnden IP-Adressen aus einem Pool aufschlagen. Damit können unter Umständen Probleme bei der Bewertung entstehen. Diese schalten wir dann bei Bedarf in der **policyd_weight_client_whitelist** frei.
  
  
Zeile 105: Zeile 423:
 </WRAP> </WRAP>
  
 +==== Postfix Konfiguration ====
 +Bei der [[centos:mail_c7:mta_4|Grundkonfiguration]] unseres Postfix-SMTP-Servers hatten wir bereits im Abschnitt [[centos:mail_c7:mta_4#smtp_recipient_restrictions|SMTP Recipient Restrictions]] die nötige Konfigurationszeile angelegt. Wir aktivieren also die zugehörigen beiden Optionen **check_client_access btree:/etc/postfix/policyd_weight_client_whitelist** und **check_policy_service inet:127.0.0.1:12525** in der Konfigurationsdatei.
 +   # vim /etc/postfix/main.cf
 +<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
 +           check_recipient_access btree:/etc/postfix/access_recipient-rfc
  
 +#          Black- und Whitelisting       (Kapitel 8.2.3 White- und Blacklisting)
 +           check_client_access cidr:/etc/postfix/access_client
 +           check_helo_access btree:/etc/postfix/access_helo
 +           check_sender_access btree:/etc/postfix/access_sender
 +           check_recipient_access btree:/etc/postfix/access_recipient
  
 +#          Unsere eigenen Nutzer zulassen-/erlauben             
 +#                                (Kapitel 8.2.2 Relaying erlauben und verbieten)
 +           permit_sasl_authenticated
 +           permit_mynetworks
 +
 +#          RBL überprüfen               (Kapitel 10.11 Realtime Blackhole Lists)
 +           reject_rbl_client zen.spamhaus.org
 +           reject_rbl_client ix.dnsbl.manitu.net
 +           reject_rbl_client bl.spamcop.net
 +           reject_rhsbl_client multi.uribl.com
 +
 +#          Greylisting via postgrey checken via Unix-Socket
 +#                                          (Kapitel 9.2.5 postgrey installieren)
 +           check_policy_service unix:postgrey/socket
 +
 +#          Policyd-Weight check over TCP-Connection 
 +#                                      (Kapitel 9.3 policyd-weight installieren)
 +           check_client_access btree:/etc/postfix/policyd_weight_client_whitelist
 +           check_policy_service inet:127.0.0.1:12525
 +
 +#          Dynamische Prüfung auf existente Relay-Empfänger
 +#                            (Kapitel 12.2.2 Dynamische Empfänger-Verifizierung)
 +           reject_unverified_recipient
 +
 +#          Backupserver (MX) erlauben
 +           permit_mx_backup
 +
 +#          alles andere an relaying verbieten   
 +#                                (Kapitel 8.2.2 Relaying erlauben und verbieten)
 +           reject_unauth_destination
 +
 +#          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")
 +           check_policy_service inet:10.0.0.77:10000
 +
 +#          Zu guter Letzt alles durchlassen, was bis jetzt noch nicht 
 +#          beanstandet wurde
 +           permit
 +</code>
 +
 +===== 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
 +<code>policyd-weight.service - 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).
 +   Loaded: loaded (/usr/lib/systemd/system/policyd-weight.service; disabled)
 +   Active: active (running) since Wed 2014-11-05 16:46:56 CET; 8s ago
 +  Process: 6315 ExecStart=/usr/bin/policyd-weight start (code=exited, status=0/SUCCESS)
 + Main PID: 6316 (policyd-weight )
 +   CGroup: /system.slice/policyd-weight.service
 +           ├─6316 policyd-weight (master)
 +           └─6317 policyd-weight (cache)
 +
 +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/policyd-weight[6316]: policyd-weight 0.1.15 beta-2 started and daemonized. conf:/etc/policyd-weight.conf; GID:995 995 EGID:995 995 UID:995 E...int mode: 0
 +Nov 05 16:46:56 vml000087.dmz.nausch.org postfix/policyd-weight[6316]: cache_query: start: calling spawn_cache()
 +Nov 05 16:46:56 vml000087.dmz.nausch.org postfix/policyd-weight[6317]: cache spawned
 +Hint: Some lines were ellipsized, use -l to show in full.
 +</code>
 +
 +Im Maillog wird der Start des Daemon entsprechend dokumentiert.
 +   # less /var/log/maillog
 +<code>Nov  5 16:46:56 vml000087 postfix/policyd-weight[6316]: policyd-weight 0.1.15 beta-2 started and daemonized. conf:/etc/policyd-weight.conf; GID:995 995 EGID:995 995 UID:995 EUID:995; taint mode: 0
 +Nov  5 16:46:56 vml000087 postfix/policyd-weight[6316]: cache_query: start: calling spawn_cache()
 +Nov  5 16:46:56 vml000087 postfix/policyd-weight[6317]: cache spawned
 +</code>
 +
 +Mit Hilfe von **netstat** können wir überprüfen, ob der Port **12525** geöffnet wurde.
 +   # netstat -tulpen
 +<code>Active Internet connections (only servers)
 +Proto Recv-Q Send-Q Local Address           Foreign Address         State       User       Inode      PID/Program name    
 +tcp        0      0 0.0.0.0:25              0.0.0.0:              LISTEN      0          56505      4931/master         
 +tcp        0      0 0.0.0.0:587             0.0.0.0:              LISTEN      0          56511      4931/master         
 +tcp        0      0 127.0.0.1:12525         0.0.0.0:              LISTEN      0          67780      6316/policyd-weight 
 +tcp        0      0 0.0.0.0:465             0.0.0.0:              LISTEN      0          56517      4931/master         
 +tcp        0      0 0.0.0.0:22              0.0.0.0:              LISTEN      0          24989      1223/sshd           
 +tcp6            0 :::25                   :::                   LISTEN      0          56506      4931/master         
 +tcp6            0 :::587                  :::*                    LISTEN      0          56512      4931/master         
 +tcp6            0 :::465                  :::*                    LISTEN      0          56518      4931/master         
 +tcp6            0 :::22                   :::                   LISTEN      0          24991      1223/sshd           
 +udp        0      0 0.0.0.0:50558           0.0.0.0:                          70         21030      571/avahi-daemon:
 +udp        0      0 0.0.0.0:46503           0.0.0.0:                                   20919      594/chronyd         
 +udp        0      0 0.0.0.0:5353            0.0.0.0:                          70         21029      571/avahi-daemon:
 +udp        0      0 127.0.0.1:323           0.0.0.0:                                   20920      594/chronyd         
 +</code>
 +
 +Gleiches können wir natürlich auch mit dem Befehl **lsof** erreichen.
 +   # lsof -i:12525
 +
 +   COMMAND    PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
 +   policyd-w 6316 polw    4u  IPv4  67780      0t0  TCP localhost:12525 (LISTEN)
  
 +Damit der Daemon automatisch beim Hochfahren des Servers gestartet wird, nutzen wir folgenden Aufruf.
 +   # systemctl enable policyd-weight.service
  
 +   ln -s '/usr/lib/systemd/system/policyd-weight.service' '/etc/systemd/system/multi-user.target.wants/policyd-weight.service'
  
 +Wollen wir überprüfen ob der Dienst automatisch startet, verwenden wir folgenden Aufruf. 
  
 +   # systemctl is-enabled policyd-weight.service
  
 +   enabled
  
 +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** <code># systemctl start policyd-weight start</code>   - **Daemon starten** <code># systemctl start policyd-weight start</code>
  
 +===== FAZIT =====
 +Der Policy-Daemon **policyd-weight** hat sich, wie auch **[[centos:mail_c7:spam_1|greylisting]]** in der Abwehr von SPAM und anderen unerwünschten Verkehrs bestens bewährt, kann so doch jede Menge des unerwünschten Traffics abgelehnt werden.
 +
 +Da aber der Dienst **rfc-ignorant.org** mittlerweilen den Dienst eingestellt hat und die Gewichtung der unterschiedlichen Gewichtung von **[[http://de.wikipedia.org/wiki/DNS-based_Blackhole_List|DNSBL]]**s der Postfix Daemon **[[centos:mail_c7:spam_3|postscreen]]** bestens beherrscht, ist der Einsatz von **policyd-weight** gut zu überlegen!
 +
 +<WRAP center round tip>
 +**summa sumarum:**
 +
 +Wie auch schon beim **[[centos:mail_c7:spam_1|greylisting]]** setzt man statt auf **greylisting** und auf **policyd-weight** nunmehr besser auf **[[centos:mail_c7:spam_3|postscreen]]**!
 +
 +</WRAP>
  
 +====== Links ======
 +  * **⇐ [[centos:mail_c7:spam_1|Zurück zum Kapitel "SPAM-Abwehr mit Hilfe von Greylisting"]]**
 +  * **⇒ [[centos:mail_c7:spam_3|Weiter zum Kapitel "Postscreen - Schutz vor Überbelastung und SPAM-Abwehr"]]**
 +  * **[[centos:mail_c7:start|Zurück zum Kapitel >>Mailserverinstallation unter CentOS 7<<]]**
 +  * **[[wiki:start|Zurück zu >>Projekte und Themenkapitel<<]]**
 +  * **[[http://dokuwiki.nausch.org/doku.php/|Zurück zur Startseite]]**
  
  
  • centos/mail_c7/spam_2.1415202765.txt.gz
  • Zuletzt geändert: 05.11.2014 15:52.
  • von django