File: documentation.txt

package info (click to toggle)
policyd-weight 0.1.15.2-12
  • links: PTS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 1,824 kB
  • ctags: 275
  • sloc: perl: 2,832; sh: 201; makefile: 35
file content (215 lines) | stat: -rw-r--r-- 7,461 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
0.1.14                                                              May 10, 2007


                          policyd-weight documentation


                    1.0 ............ What is policyd-weight
                    1.1 ........ What is policyd-weight not
                    1.2 ..... Who should use policyd-weight
                    1.3 ...................... Requirements 
                    
                    2.0 .................. How does it work
                    2.1 .................. How to set it up
                    2.2 ... How to read/understand the logs
                    
                    3.0 ............................ Thanks









First things first. This documentation IS INCOMPLETE and does not always  
reflect the current state of the project which is still beta. To get an 
additional picture I suggest to also read the changelog (changes.txt). 
Documentation will be updated as soon as I have a satisfactory stable release 
in terms of: optimal usage of possible techniques, no more techniques left, 
optimal resource usage, full reliability.

I invite everyone to help on the documentation part, as this is the most 
difficult and laborious - and my English is only good enough to get a drink at 
the local pub or to ask for the right bus station; you'll know what I mean 
sooner or later  :-)

--
rob






                                      --






1.0 What is policyd-weight

    policyd-weight is a policy server for Postfix written in Perl to score
    
    - DNSBLs/RHSBLs
    - HELO argument
    - MAIL FROM: argument
    - Client IP address
    - DNS client/HELO/FROM entries (A/16 A/24 A/32, PTR/FQDN and Parent Domains
      MX/16 MX/24 MX/32 for their correctness respectively whether they match.

    Most MTAs have checks for these things built-in, but unfortunately, those 
    checks are often too restrictive, one hit will cause important mails to 
    get rejected. Thus most companies are forced to have a rather non-
    restrictive and even insecure MTA setup so they don't lose important 
    mails. policyd-weight is intented to be used right after the RCPT TO 
    command. This way neither the mail headers nor the mail body must be 
    received. This behaviour is different from other filters that must parse 
    (and receive) the complete mail.

    With the policyd-weight approach we can reject obviously faked mails and 
    MTAs that are listed in too many DNSBLs or are poorly configured. To avoid 
    using extra bandwidth for DNS queries policyd-weight caches the most     
    frequent client/sender combinations. Also, if DNS lookups are necessary 
    it does this intentionally serialized to keep lookups to a minimum.


    NOTE: It takes some time for new SPAM mailers on the Internet to get listed 
          in DNSBLs, if they behave well and don't forge everything 
          SPAM may appear as normal mail. 
          Filters such as SpamAssassin or amavisd will parse the mail and can 
          report it to DNSBLs if set up this way (consult your SPAM/virus  
          scanner's manual).


1.1 What is policyd-weight not

    policyd-weight is NOT a SPAM or Virus Filter - as it doesn't parse
    the contents of the mail.

    Also policyd-weight is not able to reject Mails bounced or forwarded by 
    correct MTAs.
    Example: you have an account at yahoo.com, and a have set it to forward
    mail to your company account. yahoo.com sends with correct MTAs, and thus
    SPAM received from your yahoo.com account will pass this filter.


1.2 Who should use policyd-weight

    For now: for Postfix users that receive or relay mail via SMTP and for 
    people that 
    - receive lots of e-mails caught by SpamAssassin or amavisd 
      (I'm talking about +300/day). 
    - want to reduce bandwidth-usage caused by bogus mails 
      (forged SPAM/virus mails)
    - want to reduce CPU usage caused by scanning bogus mails.
    - don't want to lose legitimate mails due to overly restrictive 
      header checks
    - want to reduce bounce mails from internal servers or filters


1.3 Requirements

    Postfix       version 2.1 or higher (tested with 2.1.5 and 2.3.1)
    Perl 5.8      version 5.8 recommended, 5.6 might work, too
    Perl modules  Fcntl (standard in Perl 5.8.8)
                  Sys::Syslog
                  Net::DNS

    Mail must be accepted directly from the Internet (aka first in line)
    A fast caching DNS server in your network is highly recommended!
   

2.0 How does it work

    Well, slightly different from beta to beta. 
    -> to be continued after a stable release


2.1 How to set it up

    - copy policyd-weight to the proper location for your OS, i.e.
      /usr/local/bin/policyd-weight

    - set correct permissions:
      chown root /usr/local/bin/policyd-weight
      chgrp wheel /usr/local/bin/policyd-weight
      chmod 0755 /usr/local/bin/policyd-weight

    - create a Unix system account for user and group "polw",
      the user does not need a shell or a home directory

    - create an rc init script or manage otherwise so that
      "/usr/local/bin/policyd-weight start" gets executed before
      Postfix at boot-time

    - remove unnecessary reject_rbl_client and reject_rhsbl_client checks 
      from Postfix' main.cf

    - edit:
    [main.cf]:

    smtpd_recipient_restrictions =
        permit_mynetworks,
        ...
        reject_unauth_destination,
        check_policy_service inet:127.0.0.1:12525
        ...

    Important, keep your old SASL permits (permit_sasl_authenticated), they 
    must come before check_policy_service

    If you are using Postfix servers on different hosts you can let other 
    Postfix instances ask the server on which policyd-weight runs by using
    in their main.cf:
    
    smtpd_recipient_restrictions =
        ...
        reject_unauth_destination
        check_policy_service inet:$POLICY_SERVER_IP:12525
    
    where $POLICY_SERVER_IP needs to be replaced with the IP of the server
    which runs policyd-weight.

    Also you need to set $BIND_ADDRESS = 'all'; in /policyd-weight.conf
    Make sure that only your own Postfix servers are allowed to connect to
    that port by adjusting your firewall rules. policyd-weight has NO ACL
    mechanism for that due to performance and anti-DoS reasons. 


    For adjusting scores or other policyd-weight parameters you can create
    /etc/policyd-weight.conf and insert the changed parameter/value there.
    To see the available configuration options execute
    "policyd-weight defaults". It is good practice to only add changed 
    parameters to the config file and omit the defaults, so the file
    can more easily be maintained.

    "policyd-weight --help" gives a short help on how to use the 
    command-line switches.


2.2 How to read/understand the logs

    To see mails rejected by policyd-weight:

    	grep "policyd-weight.*action=" /var/log/maillog | grep -v DUNNO
    
    To see mails accepted by policyd-weight:

    	grep "policyd-weight.*action=" /var/log/maillog | grep DUNNO

    ...to be continued.


3.0 Thanks

    Ralf Hildebrandt, it was him who set me on fire, also for his tests.
    Bob Tito, for testing and feeding me with results
    Philipp Koller for his patches and help on Solaris, documentation and 
    website.
    All Spammers that provided me with food and enlargement pills.
    To the mailing-list users which reported bugs and odd behavior.