{"id":614,"date":"2018-02-07T13:26:54","date_gmt":"2018-02-07T13:26:54","guid":{"rendered":"http:\/\/simkin.org\/wordpress\/?p=614"},"modified":"2018-02-07T13:26:54","modified_gmt":"2018-02-07T13:26:54","slug":"blocking-spammers-by-ip-address-in-postfix","status":"publish","type":"post","link":"http:\/\/simkin.org\/wordpress\/?p=614","title":{"rendered":"Blocking Spammers by IP address in Postfix"},"content":{"rendered":"<p>I&#8217;ve had a few unwelcome visitors to my mail server and for the most part, the filters I have in place are keeping them at bay. However, there are a few determined bots that whilst not being able to bypass my filters, they do appear too often in my logs to let me just ignore them. They deserve my very specific attention. So, herein the guide to blocking senders by IP address in Postfix:<br \/>\nCreate your blacklist in a text file called \/etc\/postfix\/client_checks in the following format:<\/p>\n<pre>39.109.123.121\u00a0 \u00a0 \u00a0REJECT Your IP is blacklisted\n52.175.18.205\u00a0 \u00a0 \u00a0 REJECT Your IP is blacklisted\n112.102.225.21\u00a0 \u00a0 \u00a0REJECT Your IP is blacklisted<\/pre>\n<pre><\/pre>\n<p>Add this check to \/etc\/postfix\/main.cf:<\/p>\n<pre>smtpd_recipient_restrictions =\n check_client_access cidr:\/etc\/postfix\/client_checks,\n ...<\/pre>\n<p>Convert the file to a hashmap and reload Postfix:<\/p>\n<pre>sudo \/usr\/sbin\/postmap client_checks\nsudo \/usr\/sbin\/postfix reload\n<\/pre>\n<p><strong>Notes:<\/strong><br \/>\n* Check you \/var\/log\/maillog to see if there are any errors caused by your changes<br \/>\n* You can also use &#8220;OK&#8221; lines rather than &#8220;REJECT &lt;text&gt;&#8221; to permit hosts that are failing checks further down because for example, their sysadmin doesn&#8217;t know how to reverse DNS<br \/>\n<em>* Further reading: http:\/\/www.postfix.org\/cidr_table.5.html<\/em><br \/>\n*We probably don&#8217;t need to generate a hashmap when using &#8220;cidr:\/&#8221; but it is an old habit I can&#8217;t break<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve had a few unwelcome visitors to my mail server and for the most part, the filters I have in &hellip; <a class=\"more-link\" href=\"http:\/\/simkin.org\/wordpress\/?p=614\">More<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"spay_email":""},"categories":[3],"tags":[138],"jetpack_featured_media_url":"","_links":{"self":[{"href":"http:\/\/simkin.org\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/614"}],"collection":[{"href":"http:\/\/simkin.org\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/simkin.org\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/simkin.org\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/simkin.org\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=614"}],"version-history":[{"count":0,"href":"http:\/\/simkin.org\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/614\/revisions"}],"wp:attachment":[{"href":"http:\/\/simkin.org\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=614"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/simkin.org\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=614"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/simkin.org\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=614"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}