Integrating amavisd-new Into Postfix For Spam- And Virus-Scanning
|
Submitted by falko (Contact Author) (Forums) on Thu, 2007-03-15 19:30. :: Anti-Spam/Virus | Debian | Ubuntu | Postfix
Integrating amavisd-new Into Postfix For Spam- And Virus-ScanningVersion 1.0 This article shows how to integrate amavisd-new into a Postfix mail server for spam- and virus-scanning. amavisd-new is a high-performance interface between MTAs such as Postfix and content checkers: virus scanners, and/or SpamAssassin. We will use ClamAV for virus scanning and SpamAssassin for spam scanning in this tutorial. I want to say first that this is not the only way of setting up such a system. There are many ways of achieving this goal but this is the way I take. I do not issue any guarantee that this will work for you!
1 Preliminary NoteIn this tutorial I will describe how to install/configure amavisd-new on Debian Etch/Ubuntu 6.10 Edgy Eft (the steps are identical for both distributions) and on Debian Sarge. The amavisd-new configuration is suitable for systems where system users are used for email accounts; if you use virtual users, a few modifications to the amavisd-new configuration might or might not be required (but that depends on the actual setup). If you use virtual email users, take a look at these two tutorials:
amavisd-new works like this: Postfix receives an email on port 25, passes it to amavisd-new on port 10024 which then invokes ClamAV and SpamAssassin, and afterwards amavisd-new re-injects the mail into Postfix on port 10025 which then finally delivers the mail (if it's clean). Here's a small layout of the process: [SpamAssassin] I assume that Postfix and your email accounts are already set up and working as I don't cover Postfix installation/configuration here. All steps in this tutorial are done as root, so make sure you're logged in as root.
2 Debian Etch/Ubuntu 6.10 Edgy EftFirst we install amavisd-new, SpamAssassin, and ClamAV together with a few other programs (mainly programs that amavisd-new needs to unpack archives, because emails can contain archives as attachments): apt-get install amavisd-new spamassassin clamav clamav-daemon zoo unzip bzip2 unzoo libnet-ph-perl libnet-snpp-perl libnet-telnet-perl nomarch lzop Afterwards we must configure amavisd-new. The configuration is split up in various files which reside in the /etc/amavis/conf.d directory. Take a look at each of them to become familiar with the configuration. Most settings are fine, however we must modify two files: First we must enable ClamAV and SpamAssassin in /etc/amavis/conf.d/15-content_filter_mode by uncommenting the @bypass_virus_checks_maps and the @bypass_spam_checks_maps lines: vi /etc/amavis/conf.d/15-content_filter_mode The file should look like this:
And then you should take a look at the spam settings and the actions for spam-/virus-mails in /etc/amavis/conf.d/20-debian_defaults. There's no need to change anything if the default settings are ok for you. The file contains many explanations so there's no need to explain the settings here: vi /etc/amavis/conf.d/20-debian_defaults
Afterwards, run these commands to add the clamav user to the amavis group and to restart amavisd-new and ClamAV: adduser clamav amavis Next we must edit the configuration file of the Freshclam daemon (that's the daemon that regularly and automatically fetches the newest virus signatures from a ClamAV mirror) because it contains a small bug. Open /etc/clamav/freshclam.conf and modify the NotifyClamd line as shown below: vi /etc/clamav/freshclam.conf
Then restart Freshclam (make sure no other Freshclam process (maybe of another ClamAV installation) is running because then our Freshclam will fail to start): /etc/init.d/clamav-freshclam restart Now we have to configure Postfix to pipe incoming email through amavisd-new: postconf -e 'content_filter = amavis:[127.0.0.1]:10024' Afterwards append the following lines to /etc/postfix/master.cf: vi /etc/postfix/master.cf
Then restart Postfix: /etc/init.d/postfix restart Now run netstat -tap and you should see Postfix (master) listening on port 25 (smtp) and 10025, and amavisd-new on port 10024: server1:~# netstat -tap If you like you can now add Razor, Pyzor, and DCC to SpamAssassin to improve its filtering performance. Razor, Pyzor and DCC are spamfilters that use a collaborative filtering network. To install them, run apt-get install razor pyzor dcc-client Now we have to tell SpamAssassin to use these three programs. Edit /etc/spamassassin/local.cf and add the following lines to it: vi /etc/spamassassin/local.cf
Restart amavisd-new afterwards: /etc/init.d/amavis restart That's it already. Now watch your mail log (/var/log/mail.log) to see if amavisd-new is working properly. amavisd-new will log whenever it finds a spam or virus email. When you (re)start amavisd-new it should also log that it loads its spam and virus scanning code (if not, you probably did something wrong). For taking a live look at your mail log, you can use this command: tail -f /var/log/mail.log (Press CTRL + c to leave the log.)
|




print: 
Recent comments
8 hours 39 min ago
11 hours 42 min ago
15 hours 27 min ago
17 hours 42 min ago
18 hours 44 min ago
21 hours 51 min ago
2 days 9 min ago
2 days 5 hours ago
2 days 6 hours ago
2 days 10 hours ago