At the start of all SMTP transactions, the calling machine identifies itself, literally by saying "HELO" with its computer name. If cygnus.unix-girl.com connects to the Unixwiz.net mailserver and attempts to deliver mail:
This document is new: feedback and nit-picking welcome
This HELO verb is used more for "logging" than for "authentication", but a substantial body of spamware identifies itself as the machine it's connecting to, either by name or by IP:»» 220 linux.unixwiz.net ESMTP Postfix we say... «« HELO cygnus.unix-girl.com she says... »» 250 linux.unixwiz.net we say... .... transaction continues
Even though it's "lying", it's not really forbidden by the SMTP protocol because it's not used for authentication. But because these lies are so easily detectable, we can ask the Postfix to turn away these spammer connections with very low risk of false positive.«« HELO linux.unixwiz.net liar! that's our machine name! or «« HELO 64.170.162.98 liar! that's our IP!
We've never heard of a legitimate mailserver that lies in this way. Not even one.
The main.cf file... 1 smtpd_delay_reject = yes 2 smtpd_helo_required = yes 3 smtpd_helo_restrictions = 4 permit_mynetworks, 5 check_helo_access hash:/etc/postfix/helo_access, 6 permit ...
Note that there's an extended version of this command - EHLO - and it's treated the same as HELO for the purposes of this (and the next) restrictions.
The content of the file lists the HELO string to be considered, along with a disposition. NOTE this is for Postfix 2.x.
helo_access file (Postfix 2.x)Recall that these tests are not even considered if the connection is coming from a trusted client (which might legitimately use part of our domain name in the HELO identification), so these should never be used by legitimate outsiders.64.170.162.98 REJECT Get lost - you're lying about who you are unixwiz.net REJECT Get lost - you're lying about who you are
Furthermore, the matches are done in a hierarchical manner: if the spamware identifies itself as linux.unixwiz.net, both that name, plus the short unixwiz.net are tested (and in this case, the latter would be the match).
The change to main.cf need only be made once (along with the associated postfix reload), but the helo_access file may be updated just by regenerating the hash file.
Running postmap helo_access every time you make a change can get tedious, so many mail administrators automate a bit of this by placing these database files under control of a makefile:
Note that rebuilding the DB files does not require a Postfix reload.These two SMTP transcripts show the effect of forging a name in the HELO command from an untrusted source, and we show both cases of smtpd_delay_reject. Our side is in bold
with smtp_delay_reject=yes«« 220 linux.unixwiz.net ESMTP Postfix »» HELO linux.unixwiz.net «« 250 linux.unixwiz.net »» MAIL From:<steve@spammer.bad> «« 250 Ok »» RCPT To:<steve@unixwiz.net> «« 554 <linux.unixwiz.net> Helo command rejected: Get lost - you're lying about who you are
with smtp_delay_reject=no220 linux.unixwiz.net ESMTP Postfix HELO linux.unixwiz.net 554 <linux.unixwiz.net>: Helo command rejected: Get lost - you're lying about who you are
An example log entry (wrapped for display) is:
Postfix 2.x log entry:This connection, which originated from China, tried to identify itself as our mailserver, so was sent on its way.Mar 13 13:19:10 linux postfix/smtpd[30930]: BE1624295: reject: RCPT from unknown[61.55.20.110]: 554 <64.170.162.98>: Helo command rejected: Get lost - you're lying about who you are; from=<support@support.get-top-rankings.com> to=<steve@unixwiz.net> proto=SMTP helo=<64.170.162.98>
The most obvious kind of mistake with this arrangement is rejecting mail from a trusted source that somehow didn't make it onto the mynetworks list. Since including a top-level domain name (say, example.com) will exclude that and all sub-domains (foo.example.com, etc.) from connecting. For larger or more diverse enterprises, it might be difficult to fully elaborate all the trusted networks.
In this case, the "wide-ranging" top-level domain entry may simply be too catch-all. But it's still possible to turn away a substantial portion of spam by using narrowly-tailored entries in the helo_access file.
By including the local machine's IP address and all the names as found in the MX records in the DNS, it will catch the bulk of spammers lying outright about a separated-at-birth relationship with your mailserver:
helo_access file64.170.162.98 REJECT Get lost - you're lying about who you are linux.unixwiz.net REJECT Get lost - you're lying about who you are smtp.unixwiz.net REJECT Get lost - you're lying about who you are
helo_access file (Postfix 1.x)64.170.162.98 554 Get lost - you're lying about who you are unixwiz.net 554 Get lost - you're lying about who you are
Postfix 1.x HELO rejectionThe logs are structured a bit differently: the HELO string is not named explicitly with a "helo=" tag, but included right after the 554 message (shown here in bold).»» 220 testmx.unixwiz.net ESMTP Postfix «« HELO testmx.unixwiz.net »» 554 <testmx.unixwiz.net>: Helo command rejected: Get lost - you're lying about who you are
postfix 1.x logsIn addition, the DISCARD action permitted by Postfix 2.x is not accepted by 1.x.Mar 13 00:31:38 louie postfix/smtpd[23716]: reject: RCPT from xl-23.syndicatesales.biz[205.252.98.230]: 554 <tcsg.net>: Helo command rejected: Access denied; from=<jenstaxi@syndicatesales.biz> to=<XXXX@tcsg.net> Mar 12 10:03:44 louie postfix/smtpd[30847]: reject: RCPT from unknown[63.175.183.74]: 550 <67.83.58.177>: Helo command rejected: Get lost - you're lying about who you are; from=<yunheeyoo@americancapital.com> to=<XXXX@tcsg.net>
Our thanks to Bob Perkins for help on this section.
Navigate: More Tech Tips