Virus checking with Postfix, ClamAV and Amavisd-new

Virus checking with Postfix, ClamAV and Amavisd-new
Author: [email protected]
It's easier then it sounds!

This is a quick'n'dirty way to setup AS/AV protection on your MX. If you're not familiar with software described here, then take a look at, and All these goodies are also available trough FreeBSD's ports collection.
You should, however, spend some time with configuration files, as they're tweaked for my server...

Setup described here is running on FreeBSD 4.6-REL (i386) with Postifx 1.1.11, Clamav 0.60_1 and Amavisd-new 20030616.p5.

Make sure you update your ports before installing the software!

General overview

In this setup, spam and virus checking is preformed on the same box.
Here's the theory:

Postfix accepts mail on port 25 and forwards it to where amavisd-new is listening. Amavisd-new does it magic with Spamassassin and ClamAV and forwards mail back to postfix instance running on
Second postfix instance isn't doing any scanning, just re-injecting mail into queue.
 e-mail --> [postifx (*:25)]             -->  [amavisd-new (] -->
[postfix (] --> [delivery agent (local/smtp/...)]
Of course, amavisd-new can run on separate machine. Just adjust listening and forwarding IP and port.

Setting up ClamAV

As root:
cd /usr/ports/security/clamav && make install clean
Configuration file: /usr/local/etc/clamav.conf.
Startup script: /usr/local/etc/rc.d/

To update ClamAV's virus database regulary, put something like this in root's crontab:
0 6 * * * /usr/local/bin/freshclam
Start clamd.

Setting up Amavisd-new

As root:
cd /usr/ports/security/amavisd-new && make install clean
Configuration file: /usr/local/etc/amavisd.conf
Startup script: /usr/local/etc/rc.d/

Start amavisd.

Setting up Postfix

Configure postfix as you would normaly. After you're satisfied, add these lines:
smtp-amavis unix -      -       n     -       3  smtp
-o smtp_data_done_timeout=1200
-o disable_dns_lookups=yes inet n - n - - smtpd
-o content_filter=
-o local_recipient_maps=
-o relay_recipient_maps=
-o smtpd_restriction_classes=
-o smtpd_client_restrictions=
-o smtpd_helo_restrictions=
-o smtpd_sender_restrictions=
-o smtpd_recipient_restrictions=permit_mynetworks,reject
-o mynetworks=
-o strict_rfc821_envelopes=yes
content_filter = smtp-amavis:[]:10024

Restart Postfix (with postfix stop; postifx start) and watch mail logs for errors. If everything went ok, you shold see clamd log (/var/amavis/clamd.log) and amavisd log (/var/amavis/amavis.log) filling up.

You should see additional mail headers in mails which go trough your mailer (X-Virus-Scanned: and X-Spam-Status:).

$Id: av.html,v 1.8 2003/11/28 09:58:53 damir Exp $


บันทึกนี้เขียนที่ GotoKnow โดย  ใน นายก๊อต:รวมแหล่งความรู้

ความเห็น (0)