Postfix Restrictions

Home » CentOS » Postfix Restrictions
CentOS 6 Comments

Hi,

I’m currently fine-tuning my mail server (Postfix and Dovecot on CentOS 7).

SPF, DKIM and DMARC work fine, now I’d like to limit the spam tsunami.

Besides the official Postfix documentation, I’ve read a few articles about Postfix spam restrictions, namely these :

7 Effective Tips for Blocking Email Spam with Postfix SMTP Server

https://wiki.CentOS.org/HowTos/postfix_restrictions

After some experimenting, here’s what I currently have on my test server:

–8<----- /etc/postfix/main.cf ----------------------------- ... smtpd_helo_required = yes smtpd_helo_restrictions = permit_mynetworks, permit_sasl_authenticated, check_helo_access hash:/etc/postfix/helo_access reject_invalid_helo_hostname, reject_non_fqdn_helo_hostname, reject_unknown_helo_hostname smtpd_sender_restrictions = permit_mynetworks, permit_sasl_authenticated, check_sender_access hash:/etc/postfix/sender_access, reject_unknown_sender_domain, reject_unknown_reverse_client_hostname, reject_unknown_client_hostname smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, check_client_access hash:/etc/postfix/rbl_override, reject_rhsbl_helo dbl.spamhaus.org, reject_rhsbl_reverse_client dbl.spamhaus.org, reject_rhsbl_sender dbl.spamhaus.org, reject_rbl_client zen.spamhaus.org --8<-------------------------------------------------------- Before committing this configuration to my main server, I thought I'd share this configuration on the list. Maybe the Postfix gurus among you have the odd comment to make. My aim is simply to eliminate as much spam as possible (that is, before adding SpamAssassin) while keeping false positives to a minimum. Any suggestions ? Niki -- Microlinux - Solutions informatiques durables 7, place de l'église - 30730 Montpezat Site : https://www.microlinux.fr Mail : info@microlinux.fr Tél. : 04 66 63 10 32 Mob. : 06 51 80 12 12

6 thoughts on - Postfix Restrictions

  • The one thing that stopped the most spam on my last mailserver was greylisting. Any mta that connects to you to send you mail, you check against a white list, and if they are not on it, you reject the connection with a ‘try again later’ code and add them to a grey list that will let them in after 10 minutes or so. The vast majority of spambots don’t queue up retries, they just move on to the next target.

    The downside of greylisting is delayed delivery of mail from non white listed servers, dependent on their retry cycle.

    I finally gave up on running my own email services and use Gmail which has excellent spam filtering

  • Am 07.06.2020 um 11:46 schrieb Nicolas Kovacs:

    Hi,

    a few points:

    – don’t split up the SMTPd_*_restrictions as shown above. It is simpler to maintain by keeping everything under SMTPd_recipient_restrictions.

    – use postscreen, it is a Postfix feature. That way relocate the RBL and RHSBL calls to postscreen in a weighted approach

    – don’t offer SMTP AUTH on SMTP port 25. Offer submission (port 587) or submissions (465) or both for your known clients. That way you can much better control what’s allowed on port 25.

    – reject_non_fqdn_helo_hostname could lead to reject valid mail, use warn_if_reject for some time to check if that would be relevant for you.

    – don’t make use of permit_mynetworks, control relaying by use of SMTP AUTH.

    Alexander

  • I hit another limitation. My backup MX handler is a 3rd party who will not use greylisting. Thus all the 1st timers I rejected just delivered to my alternate MX address and were not blocked at all.

    Jon

  • yeah, then don’t use a backup MX server at all. I dropped using one when I
    realized most spam prevention would just end up at the backup which didn’t have the same rules

    as long as your server has a decent uptime and is never down more than a few hours and that very rarely, then you really don’t need a backup server at all.

  • Don’t use a backup MX, they are a relic of the 90s when mail servers were often times not always online. a sending mail server will generally retry the message for up to five days if your MTA is down so backup MXes are really not necessary.

    As you have discovered, if you do decide to use a backup MX it really needs to have exactly the same anti-spam protections as the primary MX, but most backup MXes don’t and spammers know this. In fact many spammers will ignore the primary MX all together and push out SPAM
    directly to the backup MX.

    Peter

  • Or have your backup MX be the same as your primary and well behaved senders will try backup MX right away leading to little delay due to graylisting.