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