Create a smtp blacklist

In addition to the country blacklists discussed here, it is useful to have a simple smtp blacklist for particularly obnoxious attempts. Here I assume postfix is your MTA:

  1. Add the following line to your /etc/postfix/main.cf file:
    smtp_client_restrictions = check_client_access hash:/etc/postfix/blacklist
    smtpd_recipient_restrictions = check_client_access hash:/etc/postfix/blacklist
  2. put the following (which is just an example to start you off) into /etc/postfix/blacklist:
    adsl.tpnet.pl REJECT
    adsl.alicedsl.de REJECT
    albyny.east.verizon.net REJECT
    ttnet.net.tr REJECT
    wanadoo.fr REJECT
    # Notice that I reject entire domains in this example such as wanadoo.fr and rr.com. The reason is simple -
    # lots (and I mean lots of spam) comes from these domains and the administrators thereon seem to do little
    # about it. Sigh. So necessity means banning the entire thing.
    # refuse/allow by IP
    24.24.137.27 REJECT
    58.69.136.146 REJECT
    # and so on - just add whatever offence ips or domains you wish
  3. whenever you change your blacklist, you do not neet to restart postfix
    instead just do this:
    postmap /etc/postfix/blacklist

You can write a script to automatically scan the mail log and add the most offensive repeat attacks to the blacklist if you wish. But for small home users, it is enough just to add the worst offenders manually.