Greylisting with Postgrey & Postfix

Greylisting is a technique used to discourage spammers. It’s a lightweight approach intended to reduce spam without causing undue load to your server. It simply involves rejecting mail with a temporary error the first time that the sender contacts your Mail Transport Agent (MTA). The sender should try again later if it is not a spammer, at which time the mail will be accepted for relay or delivery.

I recently setup greylisting on my server.

The term greylisting refers only to the technique, not to a particular implementation. In my case, I use Postfix as my MTA and I use the Postgrey policy server to implement greylisting.

To install Postgrey:

$ apt-get install postgrey

Postgrey typically runs on port 60000. Make sure it is up and running:

$ netstat -lnp | grep postgrey tcp        0      0 127.0.0.1:60000         0.0.0.0:*               LISTEN     21114/postgrey.pid  

If it is not running, start it up:

$ /etc/init.d/postgrey start

The next thing to do is to configure Postfix to instruct it to use Postgrey as its policy server. In my case, I added the following to the smtpd_recipient_restrictions in /etc/postfix/main.cf:

smtpd_recipient_restrictions =     . . .     check_policy_service inet:127.0.0.1:60000,     permit

After which, Postfix needs to be restarted:

$ /etc/init.d/postfix restart

If everything is working fine you should see something like the following in /var/log/mail.info:

Aug 01 12:00:00 localhost postfix/smtpd[9999]: NOQUEUE: reject: RCPT from a.b.c.d.e[123.123.123.123]: 450 4.7.1 <xxx@yyy.zzz>: Recipient address rejected: Greylisted, see http://isg.ee.ethz.ch/tools/postgrey/help/yyy.zzz.html; from=<xxx@yyy.zzz> to=<aaa@bbb.ccc> proto=ESMTP helo=<a.b.c.d.e>

Share:
  • Digg
  • del.icio.us
  • Facebook
This entry was posted in Articles, E-mail, Linux and tagged , , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>