Spam filter gateway using linux

From My Big Bad Wiki

Jump to: navigation, search

Contents

Introduction

I have an Exchange 2003 server which has its port 25 NAT'd with my router. The SPAM that I receive has gotten so bad that I've basically stopped using that email address completely and now mostly live in Gmail. Well, I want to start using it again, so it's time to come up with a plan. I don't want to subscribe to some service, install some commercial server tool, or have to maintain some peice of software at the client level. I want this Free, Free, Free. I have some older computers laying around, time to put them back to work.

With this page, I plan document the methods I used to use a computer running Linux and FOSS to filter out SPAM and viruses and continue to deliver good emails to an internal Exchange server.

I plan to follow this guide to get me rolling. In the end, this document may look similar.

Prerequisites

Operating System

  • Base Debian 3.2(Etch) install
  • Considering moving to Ubuntu for similar instructions but newer packages

Installing and Configring Applications

Postfix

apt-get install postfix

Modify the main.cf file

pico -w /etc/postfix/main.cf

Add

myhostname = serv.domain.net
mydomain = domain.net
 myorgin = $mydomain
inet_interfaces = all
mydestination = $myhostname, localhost.$mydomain $mydomain
mynetwork_style = host
relay_domains = domain.net
transport_maps = hash:/etc/postfix/transport
append_at_myorigin = no

Create a transport file

pico -w /etc/postfix/transport

Add

domain.net               smtp:[192.168.16.2]

Run this command

postmap /etc/postfix/transport

Restart Postfix

/etc/init.d/postfix stop
/etc/init.d/postfix start

MailScanner

apt-get install mailscanner
pico -w /etc/postfix/main.cf
header_checks = regexp:/etc/postfix/header_checks
pico -w /etc/postfix/header_checks
/^Received:/ HOLD
pico -w /etc/MailScanner/MailScanner.conf
Run As User = postfix ## Uncomment this line
#Run As User = Debian-exim  ## Comment out this line
Run As Group = postfix
#Run As Group = Debian-exim
Incoming Queue Dir = /var/spool/postfix/hold
Outgoing Queue Dir = /var/spool/postfix/incoming
MTA = postfix
chown postfix.postfix /var/spool/MailScanner/
chown postfix.postfix /var/spool/MailScanner/incoming
chown postfix.postfix /var/spool/MailScanner/quarantine
chown postfix.postfix /var/lib/MailScanner/
chown postfix.postfix /var/run/MailScanner/
chown postfix.postfix /var/lock/subsys/MailScanner/
pico -w /etc/default/mailscanner
run_mailscanner=1

ClamAV

apt-get install clamav

TODOS

  • Better documentation
  • Figure out how to improve SpamAssassin (So many messages that get through are so obviously spam but with an insane low score)

Did this help you?

Please send me a comment letting me know if this helped you at all. I've had folks actually want to donate a few bucks for helping, and I want make it known that this information is provided for free.

Personal tools