xref: /netbsd-src/external/ibm-public/postfix/dist/html/POSTSCREEN_README.html (revision dd75ac5b443e967e26b4d18cc8cd5eb98512bfbf)
1<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"
2        "http://www.w3.org/TR/html4/loose.dtd">
3
4<head>
5
6<title>Postfix Postscreen Howto</title>
7
8<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
9
10</head>
11
12<body>
13
14<h1><img src="postfix-logo.jpg" width="203" height="98" ALT="">Postfix Postscreen Howto</h1>
15
16<hr>
17
18<h2> <a name="intro">Introduction</a> </h2>
19
20<p> This document describes features that are available in Postfix
213.6 and later. See <a href="POSTSCREEN_3_5_README.html">
22POSTSCREEN_3_5_README.html</a> for Postfix versions 2.8 - 3.5. </p>
23
24<p> The Postfix <a href="postscreen.8.html">postscreen(8)</a> daemon provides additional protection
25against mail server overload. One <a href="postscreen.8.html">postscreen(8)</a> process handles
26multiple inbound SMTP connections, and decides which clients may
27talk to a Postfix SMTP server process.  By keeping spambots away,
28<a href="postscreen.8.html">postscreen(8)</a> leaves more SMTP server processes available for
29legitimate clients, and delays the onset of <a
30href="STRESS_README.html">server overload</a> conditions. </p>
31
32<p> <a href="postscreen.8.html">postscreen(8)</a> should not be used on SMTP ports that receive
33mail from end-user clients (MUAs). In a typical deployment,
34<a href="postscreen.8.html">postscreen(8)</a> handles the MX service on TCP port 25, while MUA
35clients submit mail via the submission service on TCP port 587 which
36requires client authentication. Alternatively, a site could set up
37a dedicated, non-postscreen, "port 25" server that provides submission
38service and client authentication, but no MX service.  </p>
39
40<p> <a href="postscreen.8.html">postscreen(8)</a> maintains a temporary allowlist for clients that
41pass its tests; by allowing allowlisted clients to skip tests,
42<a href="postscreen.8.html">postscreen(8)</a> minimizes its impact on legitimate email traffic.
43</p>
44
45<p> <a href="postscreen.8.html">postscreen(8)</a> is part of a multi-layer defense. <p>
46
47<ul>
48
49<li> <p> As the first layer, <a href="postscreen.8.html">postscreen(8)</a> blocks connections from
50zombies and other spambots that are responsible for about 90% of
51all spam.  It is implemented as a single process to make this defense
52as inexpensive as possible. </p>
53
54<li> <p> The second layer implements more complex SMTP-level access
55checks with <a href="SMTPD_ACCESS_README.html">Postfix SMTP servers</a>,
56<a href="SMTPD_POLICY_README.html">policy daemons</a>, and
57<a href="MILTER_README.html">Milter applications</a>. </p>
58
59<li> <p> The third layer performs light-weight content inspection
60with the Postfix built-in <a href="postconf.5.html#header_checks">header_checks</a> and <a href="postconf.5.html#body_checks">body_checks</a>. This can
61block unacceptable attachments such as executable programs, and
62worms or viruses with easy-to-recognize signatures. </p>
63
64<li> <p> The fourth layer provides heavy-weight content inspection
65with external content filters. Typical examples are <a
66href="http://www.ijs.si/software/amavisd/">Amavisd-new</a>, <a
67href="http://spamassassin.apache.org/">SpamAssassin</a>, and <a
68href="MILTER_README.html">Milter applications</a>. </p>
69
70</ul>
71
72<p> Each layer reduces the spam volume. The general strategy is to
73use the less expensive defenses first, and to use the more expensive
74defenses only for the spam that remains. </p>
75
76<p> Topics in this document: </p>
77
78<ul>
79
80<li> <a href="#intro">Introduction</a>
81
82<li> <a href="#basic">The basic idea behind postscreen(8)</a>
83
84<li> <a href="#general"> General operation </a>
85
86<li> <a href="#quick">Quick tests before everything else</a>
87
88<li> <a href="#before_220"> Tests before the 220 SMTP server greeting </a>
89
90<li> <a href="#after_220">Tests after the 220 SMTP server greeting</a>
91
92<li> <a href="#other_error">Other errors</a>
93
94<li> <a href="#victory">When all tests succeed</a>
95
96<li> <a href="#config"> Configuring the postscreen(8) service</a>
97
98<li> <a href="#historical"> Historical notes and credits </a>
99
100</ul>
101
102<h2> <a name="basic">The basic idea behind postscreen(8)</a> </h2>
103
104<p> Most email is spam, and most spam is sent out by zombies (malware
105on compromised end-user computers).  Wietse expects that the zombie
106problem will get worse before things improve, if ever. Without a
107tool like <a href="postscreen.8.html">postscreen(8)</a> that keeps the zombies away, Postfix would be
108spending most of its resources not receiving email. </p>
109
110<p> The main challenge for <a href="postscreen.8.html">postscreen(8)</a> is to make an is-a-zombie
111decision based on a single measurement. This is necessary because
112many zombies try to fly under the radar and avoid spamming the same
113site repeatedly.  Once <a href="postscreen.8.html">postscreen(8)</a> decides that a client is
114not-a-zombie, it allowlists the client temporarily to avoid further
115delays for legitimate mail. </p>
116
117<p> Zombies have challenges too: they have only a limited amount
118of time to deliver spam before their IP address becomes denylisted.
119To speed up spam deliveries, zombies make compromises in their SMTP
120protocol implementation.  For example, they speak before their turn,
121or they ignore responses from SMTP servers and continue sending
122mail even when the server tells them to go away. </p>
123
124<p> <a href="postscreen.8.html">postscreen(8)</a> uses a variety of measurements to recognize
125zombies.  First, <a href="postscreen.8.html">postscreen(8)</a> determines if the remote SMTP client
126IP address is denylisted.  Second, <a href="postscreen.8.html">postscreen(8)</a> looks for protocol
127compromises that are made to speed up delivery.  These are good
128indicators for making is-a-zombie decisions based on single
129measurements.  </p>
130
131<p> <a href="postscreen.8.html">postscreen(8)</a> does not inspect message content. Message content
132can vary from one delivery to the next, especially with clients
133that (also) send legitimate email.  Content is not a good indicator
134for making is-a-zombie decisions based on single measurements,
135and that is the problem that <a href="postscreen.8.html">postscreen(8)</a> is focused on.  </p>
136
137<h2> <a name="general"> General operation </a> </h2>
138
139<p> For each connection from an SMTP client, <a href="postscreen.8.html">postscreen(8)</a> performs
140a number of tests
141in the order as described below.  Some tests introduce a delay of
142a few seconds.  <a href="postscreen.8.html">postscreen(8)</a> maintains a temporary allowlist for
143clients that pass its tests; by allowing allowlisted clients to
144skip tests, <a href="postscreen.8.html">postscreen(8)</a> minimizes its impact on legitimate email
145traffic.  </p>
146
147<p> By default, <a href="postscreen.8.html">postscreen(8)</a> hands off all connections to a Postfix
148SMTP server process after logging its findings. This mode is useful
149for non-destructive testing. </p>
150
151<p> In a typical production setting, <a href="postscreen.8.html">postscreen(8)</a> is configured
152to reject mail from clients that fail one or more tests, after
153logging the helo, sender and recipient information. </p>
154
155<p> Note: <a href="postscreen.8.html">postscreen(8)</a> is not an SMTP proxy; this is intentional.
156The purpose is to keep zombies away from Postfix, with minimal
157overhead for legitimate clients. </p>
158
159<h2> <a name="quick">Quick tests before everything else</a> </h2>
160
161<p> Before engaging in SMTP-level tests. <a href="postscreen.8.html">postscreen(8)</a> queries a
162number of local deny and allowlists. These tests speed up the
163handling of known clients. </p>
164
165<ul>
166
167<li> <a href="#perm_allow_deny"> Permanent allow/denylist test </a>
168
169<li> <a href="#temp_allow"> Temporary allowlist test </a>
170
171<li> <a href="#allow_veto"> MX Policy test </a>
172
173</ul>
174
175<h3> <a name="perm_allow_deny"> Permanent allow/denylist test </a> </h3>
176
177<p> The <a href="postconf.5.html#postscreen_access_list">postscreen_access_list</a> parameter (default: <a href="postconf.5.html#permit_mynetworks">permit_mynetworks</a>)
178specifies a permanent access list for SMTP client IP addresses. Typically
179one would specify something that allowlists local networks, followed
180by a CIDR table for selective allow- and denylisting. </p>
181
182<p> Example: </p>
183
184<pre>
185/etc/postfix/<a href="postconf.5.html">main.cf</a>:
186    <a href="postconf.5.html#postscreen_access_list">postscreen_access_list</a> = <a href="postconf.5.html#permit_mynetworks">permit_mynetworks</a>,
187        <a href="cidr_table.5.html">cidr</a>:/etc/postfix/postscreen_access.cidr
188
189/etc/postfix/postscreen_access.<a href="cidr_table.5.html">cidr</a>:
190   # Rules are evaluated in the order as specified.
191   # Denylist 192.168.* except 192.168.0.1.
192   192.168.0.1          permit
193   192.168.0.0/16       reject
194</pre>
195
196<p> See the <a href="postconf.5.html#postscreen_access_list">postscreen_access_list</a> manpage documentation for more
197details.  </p>
198
199<p> When the SMTP client address matches a "permit" action,
200<a href="postscreen.8.html">postscreen(8)</a> logs this with the client address and port number as:
201</p>
202
203<blockquote>
204<pre>
205<b>ALLOWLISTED</b> <i>[address]:port</i>
206</pre>
207</blockquote>
208
209<blockquote> <p> Use the <a href="postconf.5.html#respectful_logging">respectful_logging</a> configuration parameter to
210select a deprecated form of this logging. </p> </blockquote>
211
212<p> The allowlist action is not configurable: immediately hand off the
213connection to a Postfix SMTP server process. </p>
214
215<p> When the SMTP client address matches a "reject" action,
216<a href="postscreen.8.html">postscreen(8)</a> logs this with the client address and port number as:
217</p>
218
219<blockquote>
220<pre>
221<b>DENYLISTED</b> <i>[address]:port</i>
222</pre>
223</blockquote>
224
225<blockquote> <p> Use the <a href="postconf.5.html#respectful_logging">respectful_logging</a> configuration parameter to
226select a deprecated form of this logging. </p> </blockquote>
227
228<p> The <a href="postconf.5.html#postscreen_denylist_action">postscreen_denylist_action</a> parameter specifies the action
229that is taken next.  See "<a href="#fail_before_220">When tests
230fail before the 220 SMTP server greeting</a>" below. </p>
231
232<h3> <a name="temp_allow"> Temporary allowlist test </a> </h3>
233
234<p> The <a href="postscreen.8.html">postscreen(8)</a> daemon maintains a <i>temporary</i>
235allowlist for SMTP client IP addresses that have passed all
236the tests described below. The <a href="postconf.5.html#postscreen_cache_map">postscreen_cache_map</a> parameter
237specifies the location of the temporary allowlist.  The
238temporary allowlist is not used for SMTP client addresses
239that appear on the <i>permanent</i> access list. </p>
240
241<p> By default the temporary allowlist is not shared with other
242<a href="postscreen.8.html">postscreen(8)</a> daemons. See
243<a href="#temp_allow_sharing"> Sharing
244the temporary allowlist </a> below for alternatives. </p>
245
246<p> When the SMTP client address appears on the temporary
247allowlist, <a href="postscreen.8.html">postscreen(8)</a> logs this with the client address and port
248number as: </p>
249
250<pre>
251    <b>PASS OLD</b> <i>[address]:port</i>
252</pre>
253
254<p> The action is not configurable: immediately hand off the
255connection to a Postfix SMTP server process.  The client is
256excluded from further tests until its temporary allowlist
257entry expires, as controlled with the postscreen_*_ttl
258parameters.  Expired entries are silently renewed if possible. </p>
259
260<h3> <a name="allow_veto"> MX Policy test </a> </h3>
261
262<p> When the remote SMTP client is not on the static access list
263or temporary allowlist, <a href="postscreen.8.html">postscreen(8)</a> can implement a number of
264allowlist tests, before it grants the client a temporary allowlist
265status that allows it to talk to a Postfix SMTP server process. </p>
266
267<p> When <a href="postscreen.8.html">postscreen(8)</a> is configured to monitor all primary and
268backup MX addresses, it can refuse to allowlist clients that connect
269to a backup MX address only (an old spammer trick to take advantage
270of backup MX hosts with weaker anti-spam policies than primary MX
271hosts). </p>
272
273<blockquote> <p> NOTE: The following solution is for small sites.
274Larger sites would have to share the <a href="postscreen.8.html">postscreen(8)</a> cache between
275primary and backup MTAs, which would introduce a common point of
276failure.  </p> </blockquote>
277
278<ul>
279
280<li> <p> First, configure the host to listen on both primary and
281backup MX addresses. Use the appropriate <tt>ifconfig</tt> or <tt>ip</tt>
282command for the local operating system, or update the appropriate
283configuration files and "refresh" the network protocol stack. </p>
284
285<p> <p> Second, configure Postfix to listen on the new IP address
286(this step is needed when you have specified <a href="postconf.5.html#inet_interfaces">inet_interfaces</a> in
287<a href="postconf.5.html">main.cf</a>). </p>
288
289<li> <p> Then, configure <a href="postscreen.8.html">postscreen(8)</a> to deny the temporary allowlist
290status on the backup MX address(es).  An example for Wietse's
291server is: </p>
292
293<pre>
294/etc/postfix/<a href="postconf.5.html">main.cf</a>:
295    <a href="postconf.5.html#postscreen_allowlist_interfaces">postscreen_allowlist_interfaces</a> = !168.100.189.8 <a href="DATABASE_README.html#types">static</a>:all
296</pre>
297
298<p> Translation: allow clients to obtain the temporary allowlist
299status on all server IP addresses except 168.100.189.8, which is a
300backup MX address.  </p>
301
302</ul>
303
304<p> When a non-allowlisted client connects the backup MX address,
305<a href="postscreen.8.html">postscreen(8)</a> logs this with the client address and port number as:
306</p>
307
308<blockquote> <pre>
309<b>CONNECT from</b> <i>[address]:port</i> <b>to [168.100.189.8]:25</b>
310<b>ALLOWLIST VETO</b> <i>[address]:port</i>
311</pre> </blockquote>
312
313<blockquote> <p> Use the <a href="postconf.5.html#respectful_logging">respectful_logging</a> configuration parameter to
314select a deprecated form of this logging. </p> </blockquote>
315
316<p> Translation: the client at <i>[address]:port</i> connected to
317the backup MX address 168.100.189.8 while it was not allowlisted.
318The client will not be granted the temporary allowlist status, even
319if passes all the allowlist tests described below. </p>
320
321<h2> <a name="before_220"> Tests before the 220 SMTP server greeting </a> </h2>
322
323<p> The <a href="postconf.5.html#postscreen_greet_wait">postscreen_greet_wait</a> parameter specifies a short time
324interval before the "220 <i>text</i>..." server greeting, where
325<a href="postscreen.8.html">postscreen(8)</a> can run a number of tests in parallel. </p>
326
327<p> When a good client passes these tests, and no "<a
328href="#after_220">deep protocol tests</a>"
329are configured, <a href="postscreen.8.html">postscreen(8)</a>
330adds the client to the temporary allowlist and hands off the "live"
331connection to a Postfix SMTP server process.  The client can then
332continue as if <a href="postscreen.8.html">postscreen(8)</a> never even existed (except of course
333for the short <a href="postconf.5.html#postscreen_greet_wait">postscreen_greet_wait</a> delay).  </p>
334
335<ul>
336
337<li> <a href="#pregreet"> Pregreet test </a>
338
339<li> <a href="#dnsbl"> DNS Allow/denylist test </a>
340
341<li> <a href="#fail_before_220">When tests fail before the 220 SMTP server greeting</a>
342
343</ul>
344
345<h3> <a name="pregreet"> Pregreet test </a> </h3>
346
347<p> The SMTP protocol is a classic example of a protocol where the
348server speaks before the client. <a href="postscreen.8.html">postscreen(8)</a> detects zombies
349that are in a hurry and that speak before their turn. This test is
350enabled by default. </p>
351
352<p> The <a href="postconf.5.html#postscreen_greet_banner">postscreen_greet_banner</a> parameter specifies the <i>text</i>
353portion of a "220-<i>text</i>..." teaser banner (default: $<a href="postconf.5.html#smtpd_banner">smtpd_banner</a>).
354Note that this becomes the first part of a multi-line server greeting.
355The <a href="postscreen.8.html">postscreen(8)</a> daemon sends this before the <a href="postconf.5.html#postscreen_greet_wait">postscreen_greet_wait</a>
356timer is started.  The purpose of the teaser banner is to confuse
357zombies so that they speak before their turn. It has no effect on
358SMTP clients that correctly implement the protocol.  </p>
359
360<p> To avoid problems with poorly-implemented SMTP engines in network
361appliances or network testing tools, either exclude them from all
362tests with the <a href="postconf.5.html#postscreen_access_list">postscreen_access_list</a> feature or else specify
363an empty teaser banner: </p>
364
365<pre>
366/etc/postfix/<a href="postconf.5.html">main.cf</a>:
367    # Exclude broken clients by allowlisting. Clients in <a href="postconf.5.html#mynetworks">mynetworks</a>
368    # should always be allowlisted.
369    <a href="postconf.5.html#postscreen_access_list">postscreen_access_list</a> = <a href="postconf.5.html#permit_mynetworks">permit_mynetworks</a>,
370        <a href="cidr_table.5.html">cidr</a>:/etc/postfix/postscreen_access.cidr
371
372/etc/postfix/postscreen_access.<a href="cidr_table.5.html">cidr</a>:
373    192.168.254.0/24 permit
374</pre>
375
376<pre>
377/etc/postfix/<a href="postconf.5.html">main.cf</a>:
378    # Disable the teaser banner (try allowlisting first if you can).
379    <a href="postconf.5.html#postscreen_greet_banner">postscreen_greet_banner</a> =
380</pre>
381
382<p> When an SMTP client sends a command before the
383<a href="postconf.5.html#postscreen_greet_wait">postscreen_greet_wait</a> time has elapsed, <a href="postscreen.8.html">postscreen(8)</a> logs this as:
384</p>
385
386<pre>
387    <b>PREGREET</b> <i>count</i> <b>after</b> <i>time</i> <b>from</b> <i>[address]:port text...</i>
388</pre>
389
390<p> Translation: the client at <i>[address]:port</i> sent <i>count</i>
391bytes before its turn to speak. This happened <i>time</i> seconds
392after the <a href="postconf.5.html#postscreen_greet_wait">postscreen_greet_wait</a> timer was started.  The <i>text</i>
393is what the client sent (truncated to 100 bytes, and with non-printable
394characters replaced with C-style escapes such as \r for carriage-return
395and \n for newline). </p>
396
397<p> The <a href="postconf.5.html#postscreen_greet_action">postscreen_greet_action</a> parameter specifies the action that
398is taken next.  See "<a href="#fail_before_220">When tests fail
399before the 220 SMTP server greeting</a>" below. </p>
400
401<h3> <a name="dnsbl"> DNS Allow/denylist test </a> </h3>
402
403<p> The <a href="postconf.5.html#postscreen_dnsbl_sites">postscreen_dnsbl_sites</a> parameter (default: empty) specifies
404a list of DNS blocklist servers with optional filters and weight
405factors (positive weights for denylisting, negative for allowlisting).
406These servers will be queried in parallel with the reverse client
407IP address.  This test is disabled by default. </p>
408
409<blockquote>
410<p>
411CAUTION: when postscreen rejects mail, its SMTP reply contains the
412DNSBL domain name. Use the <a href="postconf.5.html#postscreen_dnsbl_reply_map">postscreen_dnsbl_reply_map</a> feature to
413hide "password" information in DNSBL domain names.
414</p>
415</blockquote>
416
417<p> When the <a href="postconf.5.html#postscreen_greet_wait">postscreen_greet_wait</a> time has elapsed, and the combined
418DNSBL score is equal to or greater than the <a href="postconf.5.html#postscreen_dnsbl_threshold">postscreen_dnsbl_threshold</a>
419parameter value, <a href="postscreen.8.html">postscreen(8)</a> logs this as: </p>
420
421<pre>
422    <b>DNSBL rank</b> <i>count</i> <b>for</b> <i>[address]:port</i>
423</pre>
424
425<p> Translation: the SMTP client at <i>[address]:port</i> has a combined
426DNSBL score of <i>count</i>. </p>
427
428<p> The <a href="postconf.5.html#postscreen_dnsbl_action">postscreen_dnsbl_action</a> parameter specifies the action that
429is taken when the combined DNSBL score is equal to or greater than
430the threshold.  See "<a href="#fail_before_220">When tests fail
431before the 220 SMTP server greeting</a>" below. </p>
432
433<h3> <a name="fail_before_220">When tests fail before the 220 SMTP server greeting</a> </h3>
434
435<p> When the client address matches the permanent denylist, or
436when the client fails the pregreet or DNSBL tests, the action is
437specified with <a href="postconf.5.html#postscreen_denylist_action">postscreen_denylist_action</a>, <a href="postconf.5.html#postscreen_greet_action">postscreen_greet_action</a>,
438or <a href="postconf.5.html#postscreen_dnsbl_action">postscreen_dnsbl_action</a>, respectively. </p>
439
440<dl>
441
442<dt> <b>ignore</b> (default) </dt>
443
444<dd> Ignore the failure of this test. Allow other tests to complete.
445Repeat this test the next time the client connects.  This option
446is useful for testing and collecting statistics without blocking
447mail. </dd>
448
449<dt> <b>enforce</b> </dt>
450
451<dd> Allow other tests to complete.  Reject attempts to deliver mail
452with a 550 SMTP reply, and log the helo/sender/recipient information.
453Repeat this test the next time the client connects. </dd>
454
455<dt> <b>drop</b> </dt>
456
457<dd> Drop the connection immediately with a 521 SMTP reply.  Repeat
458this test the next time the client connects. </dd>
459
460</dl>
461
462<h2> <a name="after_220">Tests after the 220 SMTP server greeting</a> </h2>
463
464<p> In this phase of the protocol, <a href="postscreen.8.html">postscreen(8)</a> implements a
465number of "deep protocol" tests. These tests use an SMTP protocol
466engine that is built into the <a href="postscreen.8.html">postscreen(8)</a> server. </p>
467
468<p> Important note: these protocol tests are disabled by default.
469They are more intrusive than the pregreet and DNSBL tests, and they
470have limitations as discussed next. </p>
471
472<ul>
473
474<li> <p> The main limitation of "after 220 greeting" tests is that
475a new client must disconnect after passing these tests (reason:
476postscreen is not a proxy).  Then the client must reconnect from
477the same IP address before it can deliver mail.  The following
478measures may help to avoid email delays: </p>
479
480<ul>
481
482<li> <p> Allow "good" clients to skip tests with the
483<a href="postconf.5.html#postscreen_dnsbl_allowlist_threshold">postscreen_dnsbl_allowlist_threshold</a> feature. This is especially effective
484for large providers that usually don't retry from the same IP
485address. </p>
486
487<li> <p> Small sites: Configure <a href="postscreen.8.html">postscreen(8)</a> to listen on multiple
488IP addresses, published in DNS as different IP addresses for the
489same MX hostname or for different MX hostnames. This avoids mail
490delivery delays with clients that reconnect immediately from the
491same IP address.  </p>
492
493<li> <p> Large sites: Share the <a href="postscreen.8.html">postscreen(8)</a> cache between different
494Postfix MTAs with a large-enough <a href="memcache_table.5.html">memcache_table(5)</a>. Again, this
495avoids mail delivery delays with clients that reconnect immediately
496from the same IP address. </p>
497
498</ul>
499
500<li> <p> <a href="postscreen.8.html">postscreen(8)</a>'s built-in SMTP engine does not implement the
501AUTH, XCLIENT, and XFORWARD features. If you need to make these
502services available on port 25, then do not enable the tests after
503the 220 server greeting. </p>
504
505<li> <p> End-user clients should connect directly to the submission
506service, so that they never have to deal with <a href="postscreen.8.html">postscreen(8)</a>'s tests.
507</p>
508
509</ul>
510
511<p> The following "after 220 greeting" tests are available: </p>
512
513<ul>
514
515<li> <a href="#pipelining">Command pipelining test</a>
516
517<li> <a href="#non_smtp">Non-SMTP command test</a>
518
519<li> <a href="#barelf">Bare newline test</a>
520
521<li> <a href="#fail_after_220">When tests fail after the 220 SMTP server greeting</a>
522
523</ul>
524
525<h3> <a name="pipelining">Command pipelining test</a> </h3>
526
527<p> By default, SMTP is a half-duplex protocol: the sender and
528receiver send one command and one response at a time.  Unlike the
529Postfix SMTP server, <a href="postscreen.8.html">postscreen(8)</a> does not announce support
530for ESMTP command pipelining.  Therefore, clients are not allowed
531to send multiple commands. <a href="postscreen.8.html">postscreen(8)</a>'s
532<a href="#after_220">deep
533protocol test</a> for this is disabled by default. </p>
534
535<p> With "<a href="postconf.5.html#postscreen_pipelining_enable">postscreen_pipelining_enable</a> = yes", <a href="postscreen.8.html">postscreen(8)</a> detects
536zombies that send multiple commands, instead of sending one command
537and waiting for the server to reply.  </p>
538
539<p> This test is opportunistically enabled when <a href="postscreen.8.html">postscreen(8)</a> has
540to use the built-in SMTP engine anyway. This is to make <a href="postscreen.8.html">postscreen(8)</a>
541logging more informative. </p>
542
543<p> When a client sends multiple commands, <a href="postscreen.8.html">postscreen(8)</a> logs this
544as: </p>
545
546<pre>
547    <b>COMMAND PIPELINING from</b> <i>[address]:port</i> <b>after</b> <i>command</i>: <i>text</i>
548</pre>
549
550<p> Translation: the SMTP client at <i>[address]:port</i> sent
551multiple SMTP commands, instead of sending one command and then
552waiting for the server to reply. This happened after the client
553sent <i>command</i>. The <i>text</i> shows part of the input that
554was sent too early; it is not logged with Postfix 2.8. </p>
555
556<p> The <a href="postconf.5.html#postscreen_pipelining_action">postscreen_pipelining_action</a> parameter specifies the action
557that is taken next.  See "<a href="#fail_after_220">When tests fail
558after the 220 SMTP server greeting</a>" below. </p>
559
560<h3> <a name="non_smtp">Non-SMTP command test</a> </h3>
561
562<p> Some spambots send their mail through open proxies. A symptom
563of this is the usage of commands such as CONNECT and other non-SMTP
564commands. Just like the Postfix SMTP server's <a href="postconf.5.html#smtpd_forbidden_commands">smtpd_forbidden_commands</a>
565feature, <a href="postscreen.8.html">postscreen(8)</a> has an equivalent <a href="postconf.5.html#postscreen_forbidden_commands">postscreen_forbidden_commands</a>
566feature to block these clients. <a href="postscreen.8.html">postscreen(8)</a>'s
567<a href="#after_220">deep
568protocol test</a> for this is disabled by default.  </p>
569
570<p> With "<a href="postconf.5.html#postscreen_non_smtp_command_enable">postscreen_non_smtp_command_enable</a> = yes", <a href="postscreen.8.html">postscreen(8)</a>
571detects zombies that send commands specified with the
572<a href="postconf.5.html#postscreen_forbidden_commands">postscreen_forbidden_commands</a> parameter. This also detects commands
573with the syntax of a message header label. The latter is a symptom
574that the client is sending message content after ignoring all the
575responses from <a href="postscreen.8.html">postscreen(8)</a> that reject mail. </p>
576
577<p> This test is opportunistically enabled when <a href="postscreen.8.html">postscreen(8)</a> has
578to use the built-in SMTP engine anyway. This is to make <a href="postscreen.8.html">postscreen(8)</a>
579logging more informative.  </p>
580
581<p> When a client sends non-SMTP commands, <a href="postscreen.8.html">postscreen(8)</a> logs this
582as: </p>
583
584<pre>
585    <b>NON-SMTP COMMAND from</b> <i>[address]:port</i> <b>after</b> <i>command: text</i>
586</pre>
587
588<p> Translation: the SMTP client at <i>[address]:port</i> sent a
589command that matches the <a href="postconf.5.html#postscreen_forbidden_commands">postscreen_forbidden_commands</a>
590parameter, or that has the syntax of a message header label (text
591followed by optional space and ":").
592The "<tt><b>after</b> <i>command</i></tt>" portion is logged with
593Postfix 2.10 and later. </p>
594
595<p> The <a href="postconf.5.html#postscreen_non_smtp_command_action">postscreen_non_smtp_command_action</a> parameter specifies
596the action that is taken next.  See "<a href="#fail_after_220">When
597tests fail after the 220 SMTP server greeting</a>" below. </p>
598
599<h3> <a name="barelf">Bare newline test</a> </h3>
600
601<p> SMTP is a line-oriented protocol: lines have a limited length,
602and are terminated with &lt;CR&gt;&lt;LF&gt;. Lines ending in a
603"bare" &lt;LF&gt;, that is newline not preceded by carriage return,
604are not allowed in SMTP.  <a href="postscreen.8.html">postscreen(8)</a>'s
605<a href="#after_220">deep
606protocol test</a> for this is disabled by default.  </p>
607
608<p> With "<a href="postconf.5.html#postscreen_bare_newline_enable">postscreen_bare_newline_enable</a> = yes", <a href="postscreen.8.html">postscreen(8)</a>
609detects clients that send lines ending in bare newline characters.
610</p>
611
612<p> This test is opportunistically enabled when <a href="postscreen.8.html">postscreen(8)</a> has
613to use the built-in SMTP engine anyway. This is to make <a href="postscreen.8.html">postscreen(8)</a>
614logging more informative.  </p>
615
616<p> When a client sends bare newline characters, <a href="postscreen.8.html">postscreen(8)</a> logs
617this as:
618</p>
619
620<pre>
621    <b>BARE NEWLINE from</b> <i>[address]:port</i> <b>after</b> <i>command</i>
622</pre>
623
624<p> Translation: the SMTP client at <i>[address]:port</i> sent a bare
625newline character, that is newline not preceded by carriage
626return.
627The "<tt><b>after</b> <i>command</i></tt>" portion is logged with
628Postfix 2.10 and later. </p>
629
630<p> The <a href="postconf.5.html#postscreen_bare_newline_action">postscreen_bare_newline_action</a> parameter specifies the
631action that is taken next.  See "<a href="#fail_after_220">When
632tests fail after the 220 SMTP server greeting</a>" below. </p>
633
634<h3> <a name="fail_after_220">When tests fail after the 220 SMTP server greeting</a> </h3>
635
636<p> When the client fails the pipelining, non-SMTP command or bare
637newline tests, the action is specified with <a href="postconf.5.html#postscreen_pipelining_action">postscreen_pipelining_action</a>,
638<a href="postconf.5.html#postscreen_non_smtp_command_action">postscreen_non_smtp_command_action</a> or <a href="postconf.5.html#postscreen_bare_newline_action">postscreen_bare_newline_action</a>,
639respectively. </p>
640
641<dl>
642
643<dt> <b>ignore</b> (default for bare newline) </dt>
644
645<dd> Ignore the failure of this test. Allow other tests to complete.
646Do NOT repeat this test before the result from some other test
647expires.
648
649This option is useful for testing and collecting statistics without
650blocking mail permanently. </dd>
651
652<dt> <b>enforce</b> (default for pipelining) </dt>
653
654<dd> Allow other tests to complete.  Reject attempts to deliver
655mail with a 550 SMTP reply, and log the helo/sender/recipient
656information.  Repeat this test the next time the client connects.
657</dd>
658
659<dt> <b>drop</b> (default for non-SMTP commands) </dt>
660
661<dd> Drop the connection immediately with a 521 SMTP reply.  Repeat
662this test the next time the client connects.  This action is
663compatible with the Postfix SMTP server's <a href="postconf.5.html#smtpd_forbidden_commands">smtpd_forbidden_commands</a>
664feature. </dd>
665
666</dl>
667
668<h2> <a name="other_error">Other errors</a> </h2>
669
670<p> When an SMTP client hangs up unexpectedly, <a href="postscreen.8.html">postscreen(8)</a> logs
671this as: </p>
672
673<pre>
674    <b>HANGUP after</b> <i>time</i> <b>from</b> <i>[address]:port</i> <b>in</b> <i>test name</i>
675</pre>
676
677<p> Translation: the SMTP client at <i>[address]:port</i> disconnected
678unexpectedly, <i>time</i> seconds after the start of the
679test named <i>test name</i>. </p>
680
681<p> There is no punishment for hanging up. A client that hangs up
682without sending the QUIT command can still pass all <a href="postscreen.8.html">postscreen(8)</a>
683tests. </p>
684
685<!--
686
687<p> While an unexpired penalty is in effect, an SMTP client is not
688allowed to pass any tests, and  <a href="postscreen.8.html">postscreen(8)</a> logs each connection
689with the remaining amount of penalty time as: </p>
690
691<pre>
692    <b>PENALTY</b> <i>time</i> <b>for</b> <i>[address]:port</i>
693</pre>
694
695<p> During this time, all attempts by the client to deliver mail
696will be deferred with a 450 SMTP status.  </p>
697
698-->
699
700<p> The following errors are reported by the built-in SMTP engine.
701This engine never accepts mail, therefore it has per-session limits
702on the number of commands and on the session length. </p>
703
704<pre>
705    <b>COMMAND TIME LIMIT</b> <b>from</b> <i>[address]:port</i> <b>after</b> <i>command</i>
706</pre>
707
708<p> Translation: the SMTP client at <i>[address]:port</i> reached the
709per-command time limit as specified with the <a href="postconf.5.html#postscreen_command_time_limit">postscreen_command_time_limit</a>
710parameter.  The session is terminated immediately.
711The "<tt><b>after</b> <i>command</i></tt>" portion is logged with
712Postfix 2.10 and later. </p>
713
714<pre>
715    <b>COMMAND COUNT LIMIT from</b> <i>[address]:port</i> <b>after</b> <i>command</i>
716</pre>
717
718<p> Translation: the SMTP client at <i>[address]:port</i> reached the
719per-session command count limit as specified with the
720<a href="postconf.5.html#postscreen_command_count_limit">postscreen_command_count_limit</a> parameter.  The session is terminated
721immediately.
722The "<tt><b>after</b> <i>command</i></tt>" portion is logged with
723Postfix 2.10 and later. </p>
724
725<pre>
726    <b>COMMAND LENGTH LIMIT from</b> <i>[address]:port</i> <b>after</b> <i>command</i>
727</pre>
728
729<p> Translation: the SMTP client at <i>[address]:port</i> reached the
730per-command length limit, as specified with the <a href="postconf.5.html#line_length_limit">line_length_limit</a>
731parameter.  The session is terminated immediately.
732The "<tt><b>after</b> <i>command</i></tt>" portion is logged with
733Postfix 2.10 and later. </p>
734
735<p> When an SMTP client makes too many connections at the same time,
736<a href="postscreen.8.html">postscreen(8)</a> rejects the connection with a 421 status code and logs: </p>
737
738<pre>
739    <b>NOQUEUE: reject: CONNECT from</b> <i>[address]:port</i><b>: too many connections</b>
740</pre>
741
742<p> The <a href="postconf.5.html#postscreen_client_connection_count_limit">postscreen_client_connection_count_limit</a> parameter controls this limit. </p>
743
744<p> When an SMTP client connects after <a href="postscreen.8.html">postscreen(8)</a> has reached a
745connection count limit, <a href="postscreen.8.html">postscreen(8)</a> rejects the connection with
746a 421 status code and logs: </p>
747
748<pre>
749    <b>NOQUEUE: reject: CONNECT from</b> <i>[address]:port</i><b>: all screening ports busy</b>
750    <b>NOQUEUE: reject: CONNECT from</b> <i>[address]:port</i><b>: all server ports busy</b>
751</pre>
752
753<p> The <a href="postconf.5.html#postscreen_pre_queue_limit">postscreen_pre_queue_limit</a> and <a href="postconf.5.html#postscreen_post_queue_limit">postscreen_post_queue_limit</a>
754parameters control these limits.  </p>
755
756<h2> <a name="victory">When all tests succeed</a> </h2>
757
758<p> When a new SMTP client passes all tests (i.e. it is not allowlisted
759via some mechanism), <a href="postscreen.8.html">postscreen(8)</a> logs this as: </p>
760
761<pre>
762    <b>PASS NEW</b> <i>[address]:port</i>
763</pre>
764
765<p> Where <i>[address]:port</i> are the client IP address and port.
766Then, <a href="postscreen.8.html">postscreen(8)</a>
767creates a temporary allowlist entry that excludes the client IP
768address from further tests until the temporary allowlist entry
769expires, as controlled with the postscreen_*_ttl parameters. </p>
770
771<p> When no "<a href="#after_220">deep protocol tests</a>" are
772configured, <a href="postscreen.8.html">postscreen(8)</a> hands off the "live" connection to a Postfix
773SMTP server process.  The client can then continue as if <a href="postscreen.8.html">postscreen(8)</a>
774never even existed (except for the short <a href="postconf.5.html#postscreen_greet_wait">postscreen_greet_wait</a> delay).
775</p>
776
777<p> When any "<a href="#after_220">deep protocol tests</a>" are
778configured, <a href="postscreen.8.html">postscreen(8)</a> cannot hand off the "live" connection to
779a Postfix SMTP server process in the middle of the session.  Instead,
780<a href="postscreen.8.html">postscreen(8)</a> defers mail delivery attempts with a 4XX status, logs
781the helo/sender/recipient information, and waits for the client to
782disconnect.  The next time the client connects it will be allowed
783to talk to a Postfix SMTP server process to deliver its mail.
784<a href="postscreen.8.html">postscreen(8)</a> mitigates the impact of this limitation by giving
785<a href="#after_220">deep protocol tests</a> a long expiration
786time. </p>
787
788<h2> <a name="config"> Configuring the postscreen(8) service</a>
789</h2>
790
791<p> <a href="postscreen.8.html">postscreen(8)</a> has been tested on FreeBSD [4-8], Linux 2.[4-6]
792and Solaris 9 systems. </p>
793
794<ul>
795
796<li> <a href="#enable"> Turning on postscreen(8) without blocking
797mail</a>
798
799<li> <a href="#starttls"> postscreen(8) TLS configuration </a>
800
801<li> <a href="#blocking"> Blocking mail with postscreen(8) </a>
802
803<li> <a href="#turnoff"> Turning off postscreen(8) </a>
804
805<li> <a href="#temp_allow_sharing"> Sharing the temporary allowlist
806</a>
807
808</ul>
809
810<h3> <a name="enable"> Turning on postscreen(8) without blocking mail</a> </h3>
811
812<p> To enable the <a href="postscreen.8.html">postscreen(8)</a> service and log client information
813without blocking mail: </p>
814
815<ol>
816
817<li> <p> Make sure that local clients and systems with non-standard
818SMTP implementations are excluded from any <a href="postscreen.8.html">postscreen(8)</a> tests. The
819default is to exclude all clients in <a href="postconf.5.html#mynetworks">mynetworks</a>. To exclude additional
820clients, for example, third-party performance monitoring tools (these
821tend to have broken SMTP implementations): </p>
822
823<pre>
824/etc/postfix/<a href="postconf.5.html">main.cf</a>:
825    # Exclude broken clients by allowlisting. Clients in <a href="postconf.5.html#mynetworks">mynetworks</a>
826    # should always be allowlisted.
827    <a href="postconf.5.html#postscreen_access_list">postscreen_access_list</a> = <a href="postconf.5.html#permit_mynetworks">permit_mynetworks</a>,
828        <a href="cidr_table.5.html">cidr</a>:/etc/postfix/postscreen_access.cidr
829
830/etc/postfix/postscreen_access.<a href="cidr_table.5.html">cidr</a>:
831    192.168.254.0/24 permit
832</pre>
833
834<li> <p> Comment out the "<tt>smtp  inet ... smtpd</tt>" service
835in <a href="master.5.html">master.cf</a>, including any "<tt>-o parameter=value</tt>" entries
836that follow.  </p>
837
838<pre>
839/etc/postfix/<a href="master.5.html">master.cf</a>:
840    #smtp      inet  n       -       n       -       -       smtpd
841    #    -o parameter=value ...
842</pre>
843
844<li> <p> Uncomment the new "<tt>smtpd pass ... smtpd</tt>" service
845in <a href="master.5.html">master.cf</a>, and duplicate any "<tt>-o parameter=value</tt>" entries
846from the smtpd service that was commented out in the previous step.
847</p>
848
849<pre>
850/etc/postfix/<a href="master.5.html">master.cf</a>:
851    smtpd     pass  -       -       n       -       -       smtpd
852        -o parameter=value ...
853</pre>
854
855<li> <p> Uncomment the new "<tt>smtp inet ... postscreen</tt>"
856service in <a href="master.5.html">master.cf</a>. </p>
857
858<pre>
859/etc/postfix/<a href="master.5.html">master.cf</a>:
860    smtp      inet  n       -       n       -       1       postscreen
861</pre>
862
863<li> <p> Uncomment the new "<tt>tlsproxy unix ... tlsproxy</tt>"
864service in <a href="master.5.html">master.cf</a>.  This service implements STARTTLS support for
865<a href="postscreen.8.html">postscreen(8)</a>. </p>
866
867<pre>
868/etc/postfix/<a href="master.5.html">master.cf</a>:
869    tlsproxy  unix  -       -       n       -       0       tlsproxy
870</pre>
871
872<li> <p> Uncomment the new "<tt>dnsblog  unix ... dnsblog</tt>"
873service in <a href="master.5.html">master.cf</a>.  This service does DNSBL lookups for <a href="postscreen.8.html">postscreen(8)</a>
874and logs results. </p>
875
876<pre>
877/etc/postfix/<a href="master.5.html">master.cf</a>:
878    dnsblog   unix  -       -       n       -       0       dnsblog
879</pre>
880
881<li> <p> To enable DNSBL lookups, list some DNS blocklist sites in
882<a href="postconf.5.html">main.cf</a>, separated by whitespace. Different sites can have different
883weights. For example:
884
885<pre>
886/etc/postfix/<a href="postconf.5.html">main.cf</a>:
887    <a href="postconf.5.html#postscreen_dnsbl_threshold">postscreen_dnsbl_threshold</a> = 2
888    <a href="postconf.5.html#postscreen_dnsbl_sites">postscreen_dnsbl_sites</a> = zen.spamhaus.org*2
889        bl.spamcop.net*1 b.barracudacentral.org*1
890</pre>
891
892<p> Note: if your DNSBL queries have a "secret" in the domain name,
893you must censor this information from the <a href="postscreen.8.html">postscreen(8)</a> SMTP replies.
894For example: </p>
895
896<pre>
897/etc/postfix/<a href="postconf.5.html">main.cf</a>:
898    <a href="postconf.5.html#postscreen_dnsbl_reply_map">postscreen_dnsbl_reply_map</a> = <a href="DATABASE_README.html#types">texthash</a>:/etc/postfix/dnsbl_reply
899</pre>
900
901<pre>
902/etc/postfix/dnsbl_reply:
903    # Secret DNSBL name           Name in <a href="postscreen.8.html">postscreen(8)</a> replies
904    secret.zen.dq.spamhaus.net    zen.spamhaus.org
905</pre>
906
907<p> The <a href="DATABASE_README.html#types">texthash</a>: format is similar to <a href="DATABASE_README.html#types">hash</a>: except that there is
908no need to run <a href="postmap.1.html">postmap(1)</a> before the file can be used, and that it
909does not detect changes after the file is read. It is new with
910Postfix version 2.8. </p>
911
912<li> <p> Read the new configuration with "<tt>postfix reload</tt>".
913</p>
914
915</ol>
916
917<p> Notes: </p>
918
919<ul>
920
921<li> <p> Some <a href="postscreen.8.html">postscreen(8)</a> configuration parameters implement
922stress-dependent behavior. This is supported only when the default
923value is stress-dependent (that is, "postconf -d <i>parametername</i>"
924output shows
925"<i>parametername</i>&nbsp;=&nbsp;${stress?<i>something</i>}${stress:<i>something</i>}" or
926"<i>parametername</i>&nbsp;=&nbsp;${stress?{<i>something</i>}:{<i>something</i>}}").
927Other parameters always evaluate as if the stress value is the empty
928string. </p>
929
930<li> <p> See "<a href="#before_220">Tests before the 220 SMTP server
931greeting</a>" for details about the logging from these
932<a href="postscreen.8.html">postscreen(8)</a> tests. </p>
933
934<li> <p> If you run Postfix 2.6 or earlier you must stop and start
935the master daemon ("<tt>postfix stop; postfix start</tt>").  This
936is needed because the Postfix "pass" master service type did not
937work reliably on all systems. </p>
938
939</ul>
940
941<h3> <a name="starttls"> postscreen(8) TLS configuration </a> </h3>
942
943<p> <a href="postscreen.8.html">postscreen(8)</a> TLS support is available for remote SMTP clients
944that aren't allowlisted, including clients that need to renew their
945temporary allowlist status.  When a remote SMTP client requests TLS
946service, <a href="postscreen.8.html">postscreen(8)</a> invisibly hands off the connection to a
947<a href="tlsproxy.8.html">tlsproxy(8)</a> process. Then, <a href="tlsproxy.8.html">tlsproxy(8)</a> encrypts and decrypts the
948traffic between <a href="postscreen.8.html">postscreen(8)</a> and the remote SMTP client. One
949<a href="tlsproxy.8.html">tlsproxy(8)</a> process can handle multiple SMTP sessions. The number
950of <a href="tlsproxy.8.html">tlsproxy(8)</a> processes slowly increases with server load, but it
951should always be much smaller than the number of <a href="postscreen.8.html">postscreen(8)</a> TLS
952sessions.  </p>
953
954<p> TLS support for <a href="postscreen.8.html">postscreen(8)</a> and <a href="tlsproxy.8.html">tlsproxy(8)</a> uses the same
955parameters as with <a href="smtpd.8.html">smtpd(8)</a>. We recommend that you keep the relevant
956configuration parameters in <a href="postconf.5.html">main.cf</a>.  If you must specify "-o
957smtpd_mumble=value" parameter overrides in <a href="master.5.html">master.cf</a> for a
958postscreen-protected <a href="smtpd.8.html">smtpd(8)</a> service, then you should specify those
959same parameter overrides for the <a href="postscreen.8.html">postscreen(8)</a> and <a href="tlsproxy.8.html">tlsproxy(8)</a>
960services. </p>
961
962<h3> <a name="blocking"> Blocking mail with postscreen(8) </a> </h3>
963
964<p> For compatibility with <a href="smtpd.8.html">smtpd(8)</a>, <a href="postscreen.8.html">postscreen(8)</a> implements the
965<a href="postconf.5.html#soft_bounce">soft_bounce</a> safety feature. This causes Postfix to reject mail with
966a "try again" reply code. </p>
967
968<ul>
969
970<li> <p> To turn this on for all of Postfix, specify "<tt><a href="postconf.5.html#soft_bounce">soft_bounce</a>
971= yes</tt>" in <a href="postconf.5.html">main.cf</a>. </p>
972
973<li> <p> To turn this on for <a href="postscreen.8.html">postscreen(8)</a> only, append "<tt>-o
974<a href="postconf.5.html#soft_bounce">soft_bounce</a>=yes</tt>" (note: NO SPACES around '=') to the postscreen
975entry in <a href="master.5.html">master.cf</a>. <p>
976
977</ul>
978
979<p> Execute "<tt>postfix reload</tt>" to make the change effective. </p>
980
981<p> After testing, do not forget to remove the <a href="postconf.5.html#soft_bounce">soft_bounce</a> feature,
982otherwise senders won't receive their non-delivery notification
983until many days later.  </p>
984
985<p> To use the <a href="postscreen.8.html">postscreen(8)</a> service to block mail, edit <a href="postconf.5.html">main.cf</a> and
986specify one or more of: </p>
987
988<ul>
989
990<li> <p> "<tt><a href="postconf.5.html#postscreen_dnsbl_action">postscreen_dnsbl_action</a> = enforce</tt>", to reject
991clients that are on DNS blocklists, and to log the helo/sender/recipient
992information. With good DNSBLs this reduces the amount of load on
993Postfix SMTP servers dramatically.  </p>
994
995<li> <p> "<tt><a href="postconf.5.html#postscreen_greet_action">postscreen_greet_action</a> = enforce</tt>", to reject
996clients that talk before their turn, and to log the helo/sender/recipient
997information. This stops over half of all known-to-be illegitimate
998connections to Wietse's mail server. It is backup protection for
999zombies that haven't yet been denylisted. </p>
1000
1001<li> <p> You can also enable "<a href="#after_220">deep protocol
1002tests</a>", but these are more intrusive than the pregreet or DNSBL
1003tests. </p>
1004
1005<p> When a good client passes the "<a href="#after_220">deep
1006protocol tests</a>",
1007<a href="postscreen.8.html">postscreen(8)</a> adds the client to the temporary
1008allowlist but it cannot hand off the "live" connection to a Postfix
1009SMTP server process in the middle of the session. Instead, <a href="postscreen.8.html">postscreen(8)</a>
1010defers mail delivery attempts with a 4XX status, logs the
1011helo/sender/recipient information, and waits for the client to
1012disconnect. </p>
1013
1014<p> When the good client comes back in a later session, it is allowed
1015to talk directly to a Postfix SMTP server.  See "<a href="#after_220">Tests
1016after the 220 SMTP server greeting</a>" above for limitations with
1017AUTH and other features that clients may need.  </p>
1018
1019<p> An unexpected benefit from "<a href="#after_220">deep protocol
1020tests</a>" is that some "good" clients don't return after the 4XX
1021reply; these clients were not so good after all. </p>
1022
1023<p> Unfortunately, some senders will retry requests from different
1024IP addresses, and may never get allowlisted.  For this reason,
1025Wietse stopped using "<a href="#after_220">deep protocol tests</a>"
1026on his own internet-facing mail server.  </p>
1027
1028<li> <p> There is also support for permanent denylisting and
1029allowlisting; see the description of the <a href="postconf.5.html#postscreen_access_list">postscreen_access_list</a>
1030parameter for details. </p>
1031
1032</ul>
1033
1034<h3> <a name="turnoff"> Turning off postscreen(8) </a> </h3>
1035
1036<p> To turn off <a href="postscreen.8.html">postscreen(8)</a> and handle mail directly with Postfix
1037SMTP server processes: </p>
1038
1039<ol>
1040
1041<li> <p> Comment out the "<tt>smtp inet ... postscreen</tt>" service
1042in <a href="master.5.html">master.cf</a>, including any "<tt>-o parameter=value</tt>" entries
1043that follow. </p>
1044
1045<pre>
1046/etc/postfix/<a href="master.5.html">master.cf</a>:
1047    #smtp      inet  n       -       n       -       1       postscreen
1048    #    -o parameter=value ...
1049</pre>
1050
1051<li> <p> Comment out the "<tt>dnsblog  unix ... dnsblog</tt>" service
1052in <a href="master.5.html">master.cf</a>.  </p>
1053
1054<pre>
1055/etc/postfix/<a href="master.5.html">master.cf</a>:
1056    #dnsblog   unix  -       -       n       -       0       dnsblog
1057</pre>
1058
1059<li> <p> Comment out the "<tt>smtpd pass ... smtpd</tt>" service
1060in <a href="master.5.html">master.cf</a>, including any "<tt>-o parameter=value</tt>" entries
1061that follow. </p>
1062
1063<pre>
1064/etc/postfix/<a href="master.5.html">master.cf</a>:
1065    #smtpd     pass  -       -       n       -       -       smtpd
1066    #    -o parameter=value ...
1067</pre>
1068
1069<li> <p> Comment out the "<tt>tlsproxy unix ... tlsproxy</tt>"
1070service in <a href="master.5.html">master.cf</a>, including any "<tt>-o parameter=value</tt>"
1071entries that follow. </p>
1072
1073<pre>
1074/etc/postfix/<a href="master.5.html">master.cf</a>:
1075    #tlsproxy  unix  -       -       n       -       0       tlsproxy
1076    #    -o parameter=value ...
1077</pre>
1078
1079<li> <p> Uncomment the "<tt>smtp  inet ... smtpd</tt>" service in
1080<a href="master.5.html">master.cf</a>, including any "<tt>-o parameter=value</tt>" entries that
1081may follow.  </p>
1082
1083<pre>
1084/etc/postfix/<a href="master.5.html">master.cf</a>:
1085    smtp       inet  n       -       n       -       -       smtpd
1086        -o parameter=value ...
1087</pre>
1088
1089<li> <p> Read the new configuration with "<tt>postfix reload</tt>".
1090</p>
1091
1092</ol>
1093
1094<h3> <a name="temp_allow_sharing"> Sharing the temporary allowlist </a> </h3>
1095
1096<p> By default, the temporary allowlist is not shared between
1097multiple <a href="postscreen.8.html">postscreen(8)</a> daemons.  To enable sharing, choose one
1098of the following options: </p>
1099
1100<ul>
1101
1102<li> <p> A non-persistent <a href="memcache_table.5.html">memcache</a>: temporary allowlist can be shared
1103    between <a href="postscreen.8.html">postscreen(8)</a> daemons on the same host or different
1104    hosts.  Disable cache cleanup (<a href="postconf.5.html#postscreen_cache_cleanup_interval">postscreen_cache_cleanup_interval</a>
1105    = 0) in all <a href="postscreen.8.html">postscreen(8)</a> daemons because <a href="memcache_table.5.html">memcache</a>: has no
1106    first-next API (but see example 4 below for <a href="memcache_table.5.html">memcache</a>: with
1107    persistent backup). This requires Postfix 2.9 or later. </p>
1108
1109    <pre>
1110    # Example 1: non-persistent <a href="memcache_table.5.html">memcache</a>: allowlist.
1111    /etc/postfix/<a href="postconf.5.html">main.cf</a>:
1112        <a href="postconf.5.html#postscreen_cache_map">postscreen_cache_map</a> = <a href="memcache_table.5.html">memcache</a>:/etc/postfix/postscreen_cache
1113        <a href="postconf.5.html#postscreen_cache_cleanup_interval">postscreen_cache_cleanup_interval</a> = 0
1114
1115    /etc/postfix/postscreen_cache:
1116        memcache = inet:127.0.0.1:11211
1117        key_format = postscreen:%s
1118    </pre>
1119
1120<li> <p>
1121    A persistent <a href="lmdb_table.5.html">lmdb</a>: temporary allowlist can be shared between
1122    <a href="postscreen.8.html">postscreen(8)</a> daemons that run under the same <a href="master.8.html">master(8)</a> daemon,
1123    or under different <a href="master.8.html">master(8)</a> daemons on the same host.  Disable
1124    cache cleanup (<a href="postconf.5.html#postscreen_cache_cleanup_interval">postscreen_cache_cleanup_interval</a> = 0) in all
1125    <a href="postscreen.8.html">postscreen(8)</a> daemons except one that is responsible for cache
1126    cleanup. This requires Postfix 2.11 or later. </p>
1127
1128    <pre>
1129    # Example 2: persistent <a href="lmdb_table.5.html">lmdb</a>: allowlist.
1130    /etc/postfix/<a href="postconf.5.html">main.cf</a>:
1131        <a href="postconf.5.html#postscreen_cache_map">postscreen_cache_map</a> = <a href="lmdb_table.5.html">lmdb</a>:$<a href="postconf.5.html#data_directory">data_directory</a>/postscreen_cache
1132        # See note 1 below.
1133        # <a href="postconf.5.html#postscreen_cache_cleanup_interval">postscreen_cache_cleanup_interval</a> = 0
1134    </pre>
1135
1136<li> <p> Other kinds of persistent temporary allowlist can be shared
1137    only between <a href="postscreen.8.html">postscreen(8)</a> daemons that run under the same
1138    <a href="master.8.html">master(8)</a> daemon. In this case, temporary allowlist access must
1139    be shared through the <a href="proxymap.8.html">proxymap(8)</a> daemon. This requires Postfix
1140    2.9 or later. </p>
1141
1142    <pre>
1143    # Example 3: proxied <a href="DATABASE_README.html#types">btree</a>: allowlist.
1144    /etc/postfix/<a href="postconf.5.html">main.cf</a>:
1145        <a href="postconf.5.html#postscreen_cache_map">postscreen_cache_map</a> =
1146            <a href="proxymap.8.html">proxy</a>:<a href="DATABASE_README.html#types">btree</a>:/var/lib/postfix/postscreen_cache
1147        # See note 1 below.
1148        # <a href="postconf.5.html#postscreen_cache_cleanup_interval">postscreen_cache_cleanup_interval</a> = 0
1149
1150    # Example 4: proxied <a href="DATABASE_README.html#types">btree</a>: allowlist with <a href="memcache_table.5.html">memcache</a>: accelerator.
1151    /etc/postfix/<a href="postconf.5.html">main.cf</a>:
1152        <a href="postconf.5.html#postscreen_cache_map">postscreen_cache_map</a> = <a href="memcache_table.5.html">memcache</a>:/etc/postfix/postscreen_cache
1153        <a href="postconf.5.html#proxy_write_maps">proxy_write_maps</a> =
1154            <a href="proxymap.8.html">proxy</a>:<a href="DATABASE_README.html#types">btree</a>:/var/lib/postfix/postscreen_cache
1155            ... other proxied tables ...
1156        # See note 1 below.
1157        # <a href="postconf.5.html#postscreen_cache_cleanup_interval">postscreen_cache_cleanup_interval</a> = 0
1158
1159    /etc/postfix/postscreen_cache:
1160        # Note: the $<a href="postconf.5.html#data_directory">data_directory</a> macro is not defined in this context.
1161        memcache = inet:127.0.0.1:11211
1162        backup = <a href="proxymap.8.html">proxy</a>:<a href="DATABASE_README.html#types">btree</a>:/var/lib/postfix/postscreen_cache
1163        key_format = postscreen:%s
1164    </pre>
1165
1166    <p> Note 1: disable cache cleanup (<a href="postconf.5.html#postscreen_cache_cleanup_interval">postscreen_cache_cleanup_interval</a>
1167    = 0) in all <a href="postscreen.8.html">postscreen(8)</a> daemons except one that is responsible
1168    for cache cleanup. </p>
1169
1170    <p> Note 2: <a href="postscreen.8.html">postscreen(8)</a> cache sharing via <a href="proxymap.8.html">proxymap(8)</a> requires Postfix
1171    2.9 or later; earlier <a href="proxymap.8.html">proxymap(8)</a> implementations don't support
1172    cache cleanup.  </p>
1173
1174</ul>
1175
1176<h2> <a name="historical"> Historical notes and credits </a> </h2>
1177
1178<p> Many ideas in <a href="postscreen.8.html">postscreen(8)</a> were explored in earlier work by
1179Michael Tokarev, in OpenBSD spamd, and in MailChannels Traffic
1180Control. </p>
1181
1182<p> Wietse threw together a crude prototype with pregreet and dnsbl
1183support in June 2009, because he needed something new for a Mailserver
1184conference presentation in July. Ralf Hildebrandt ran this code on
1185several servers to collect real-world statistics. This version used
1186the <a href="dnsblog.8.html">dnsblog(8)</a> ad-hoc DNS client program. </p>
1187
1188<p> Wietse needed new material for a LISA conference presentation
1189in November 2010, so he added support for DNSBL weights and filters
1190in August, followed by a major code rewrite, deep protocol tests,
1191helo/sender/recipient logging, and stress-adaptive behavior in
1192September. Ralf Hildebrandt ran this code on several servers to
1193collect real-world statistics. This version still used the embarrassing
1194<a href="dnsblog.8.html">dnsblog(8)</a> ad-hoc DNS client program.  </p>
1195
1196<p> Wietse added STARTTLS support in December 2010. This makes
1197<a href="postscreen.8.html">postscreen(8)</a> usable for sites that require TLS support.  The
1198implementation introduces the <a href="tlsproxy.8.html">tlsproxy(8)</a> event-driven TLS proxy
1199that decrypts/encrypts the sessions for multiple SMTP clients. </p>
1200
1201<p> The <a href="tlsproxy.8.html">tlsproxy(8)</a> implementation led to the discovery of a "new"
1202class of vulnerability (<a
1203href="http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2011-0411"
1204>CVE-2011-0411</a>) that affected multiple implementations of SMTP,
1205POP, IMAP, NNTP, and FTP over TLS. </p>
1206
1207<p> <a href="postscreen.8.html">postscreen(8)</a> was officially released as part of the Postfix
12082.8 stable release in January 2011.</p>
1209
1210<p> Noel Jones helped with the Postfix 3.6 transition towards respectful
1211documentation. </p>
1212
1213</body>
1214</html>
1215