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