Current Document and Section   Other Documents  
  - Documentation
    - Howtos
  User Guide
DNS and Domains
Gateway Services Guide
Release Notes
 
 

Howtos - Anti-Virus and Anti-Spam Filtering with MailScanner

Warning! 
 

This document is either no longer maintained or deprecated.  Use with caution!

 
 


 
  This Howto is intended for version 3.x. Antivirus and Dual-Antispam were added in ClarkConnect 4.0.  
 


Contents

[edit] Overview

MailScanner is a highly-respected open-source e-mail security system that scans all e-mail for viruses, spam and attacks against security vulnerabilities. It is not tied to any particular virus scanner and may be used with any combination of 14 different virus scanners. This document explains how to install MailScanner using a single copy of Postfix to handle both incoming and outgoing mail delivery.

The approach described here does not require Mailscanner to access the active queue. Instead Postfix puts all incoming email into a hold queue so Mailscanner can safely access these emails for scanning and then pass them back to the Postfix active queue for delivery.

Anti-virus and anti-spam filtering is provided by the following optional components:

  • AntiVir
  • BitDefender
  • ClamAV
  • SpamAssassin
  • Webmin modules
 
  The contents of this howto have been successfully tested on ClarkConnect Home Edition 3.1 and 3.2.  
 


Warning! 
  Some components may only be used freely for private, non-commerical or personal use.  
 

[edit] Installing AntirVir

AntiVir is provided courtesy of AntiVir PersonalProducts GmbH. The private, non-commercial use of AntiVir Workstation for Linux is free. Please check their Web site for the latest version. To install AntiVir, use the following commands:

The default settings offered by the script are acceptable since MailScanner will ensure the virus definitions are kept up-to-date. To update AntiVir type from the command line:

  • antivir --update

To scan from the command line use:

  • antivir

[edit] Installing BitDefender

BitDefender is provided courtesy of SOFTWIN SRL. BitDefender Linux Edition is a freeware product, which doesn't require a license to be used. Please check their Web site for the latest version. To install BitDefender, use the following commands:

To update BitDefender from the command line use:

  • bdc --update

To scan from the command line use:

  • bcd

[edit] Installing ClamAV

ClamAV is a free anti-virus toolkit for UNIX and is provided courtesy of the ClamAV Project. Clam AntiVirus is licensed under the GNU Public Licence. Packages used in this Howto are either built and/or maintained by Dag Wieers. Please check each Web site for the latest versions. To install ClamAV, use the following commands:

To update ClamAV from the command line use:

  • freshclam

To scan from the command line use:

  • clamdscan

[edit] Installing SpamAssassin

SpamAssassin is an open-source spam filter provided courtesy of The Apache SpamAssassin Project. Clam AntiVirus is licensed under the GNU Public Licence. Please check their Web site for the latest version. To install SpamAssassin simply use the following command:

  • apt-get install spamassassin
Warning! 
  Remove cc-spamassassin before installing spamassassin.  
 

[edit] Install and configure MailScanner

MailScanner is developed by the Electronics and Computer Science Department at the University of Southampton and is distributed for free under the GNU Public Licence. Please check their Web site for the latest version.

Before you proceed any further you will need to install the ClarkConnect developer tools on your system. For instructions go to the following howto: Installing and Removing the Developer Tools. To install MailScanner, use the following commands:

Installing MailScanner will generate lots of output; ensure it finishes without error before proceeding.

 
  Now is a good time to backup your configuration!  
 


Warning! 
  Don't forget to remove the Developer Tools.  
 


If necessary, execute the following commands before configuring MailScanner:

  • service postfix stop
  • chkconfig postfix off

Open /etc/postfix/main.cf and make sure that you add the following line:

header_checks = regexp:/etc/postfix/header_checks

Next, open the file /etc/postfix/header_checks and add this line:

/^Received:/ HOLD

This tells Postfix to move all messages to the HOLD queue. Now edit the file /etc/MailScanner/MailScanner.conf and change the following 6 settings, which are all near the top of the file:

Run As User = postfix
Run As Group = postfix
Incoming Queue Dir = /var/spool/postfix/hold
Outgoing Queue Dir = /var/spool/postfix/incoming
MTA = postfix
SpamAssassin User State Dir = /var/spool/MailScanner/spamassassin

Next, make sure Postfix can write to /var/spool/MailScanner/incoming and /var/spool/MailScanner/quarantine:

  • chown postfix.postfix /var/spool/MailScanner/incoming
  • chown postfix.postfix /var/spool/MailScanner/quarantine

Finally, execute the following commands and you're ready for testing:

  • mkdir /var/spool/MailScanner/spamassassin
  • chown postfix.postfix /var/spool/MailScanner/spamassassin
  • mkdir /var/spool/mqueue
  • chown postfix.postfix /var/spool/mqueue
  • touch /var/lock/subsys/MailScanner.off
 
  If you have not already done so, open port 25 using Webconfig.  
 

[edit] Using MailScanner

Now you are ready to test MailScanner without using anti-virus or anti-spam filtering:

  • service MailScanner start

If you can successfully send and recieve mail start adding virus scanners and SpamAssassin one at a time. Modify /etc/MailScanner/MailScanner.conf accordingly:

Virus Scanning = yes
Virus Scanners = antivir bitdefender clamav
Use SpamAssassin = yes
Notify Senders = no

Once you are satisfied that everything is working correctly, edit the organisation and server identification information:

%org-name% = YOURSITENAME
%org-long-name% = The name of your organisation
%web-site% = www.yoursite.com

Finally, you need to amend the virus scanner wrapper so that ClamAV is automatically updated. Modify /etc/MailScanner/virus.scanners.conf:

clamav /usr/lib/MailScanner/clamav-wrapper /usr/bin/clamdscan


You may test this by issuing the following from the shell:

  • /usr/lib/MailScanner/clamav-wrapper /usr/bin/clamdscan /tmp

[edit] Optional Webmin modules

Webmin modules are available for BitDefender (excludes Linux Edition), ClamAv and MailScanner. Download the modules you require from the respective Web sites (see links below) and install using Webmin:

Alternatively, issue the following commands from the shell (single example shown):

[edit] Configuring Clam Antivirus management module

The Clam Antivirus Webmin module provides a simple front-end for administering Clam Antivirus and is licensed under the GNU Public Licence. Edit the configurable options for Clam Antivirus as follows:

Option Setting
Working path /tmp
Use the following content scanner → MailScanner
Path to quarantine repository /var/spool/MailScanner/quarantine
Path of ClamAV binaries /usr/bin/
Path to daemon init script /etc/init.d/clamd
Path to logfile /var/log/clamav/clamav.log
Path to configuration file /etc/clamd.conf
Path to main virus signatures database /var/clamav/main.cvd
Path to daily virus signatures database /var/clamav/daily.cvd
Path to configuration file /etc/freshclam.conf
Method to use to refresh automatically viruses database? → Daemon
Path to logfile /var/log/clamav/freshclam.log
Path to daemon init script /etc/cron.daily/freshclam

[edit] Configuring MailScanner Front End

The MailScanner Webmin module provides a simple front-end for administering MailScanner and is in the Public Domain. Edit the configurable options for MailScanner as follows:

Option Setting
Full path to MailScanner program /usr/sbin/MailScanner
Full path and filename of MailScanner config file /etc/MailScanner/MailScanner.conf
Full path to the MailScanner bin directory /usr/sbin
Full path and filename for the MailScanner pid file /var/run/MailScanner.pid
Command to start MailScanner → Just run server
Command to stop MailScanner service MailScanner stop

[edit] Links

Retrieved from "http://www.clarkconnect.com/docs/Howtos_-_Anti-Virus_and_Anti-Spam_Filtering_with_MailScanner"

This page has been accessed 4,334 times. This page was last modified 22:39, 24 April 2007.