SENDMAIL CONTENT SCANNING:
Configuring the full functional content scanning using Mailscanner, Clamav and Spamassassin
Initially we will configure the clamav antivirus.
CLAMAV ANTIVIRUS:
Installation of CLAMAV Antivirus:
Download the Source code of the software
# wget http://sourceforge.net/projects/clamav/files/clamav/0.95.2/clamav-0.95.2.tar.gz/download
# tar -zxvf clamav-0.95.2.tar.gz
# cd clamav-0.95.2
1. zlibs It needs zlib-1.2.2 atleast
zlibs-devel
2. bzip2
bzip2-libs
bzip2-devel
3. gmp
4. curl
curl-devel
#groupadd clamav
#useradd -g clamav -s /sbin/nologin clamav
# ./configure
# make
# make install
Configuring CLAMAV Antivirus:
#cd /usr/loca/etc
For starting the clamd daemon, have to edit the following parameters in clamd.conf
#vim clamd.conf
#comment out the Example
#Example
#vim freshclam.conf
#comment out the Example
#Example
#touch /var/log/freshclam.log
#chmod 600 /var/log/freshclam.log
#chown clamav.clamav /var/log/freshclam.log
#freshclam
#/usr/loca/bin/freshclam -d
It is time to start the clamd daemon now.
#/usr/local/sbin/clamd
#ps -ef |grep clam
Adding clamd daemon to init startup(This part is optional).
#cd clamav-ver/contrib/init
#vim clamd
#cp clamd /etc/init.d
Now start configuring the Spamassassin
SPAMASSASSIN:
Installation:
Download the Source code of the software
# wget http://www.bizdirusa.com/mirrors/apache/spamassassin/source/Mail-SpamAssassin-3.2.5.tar.bz2
# tar -jxvf Mail-SpamAssassin-3.2.5.tar.bz2
# cd Mail-SpamAssassin-3.2.5
1. HTML::Parser
Install the pre-requiesties using cpanel.
#cpanel
>install HTML::Parser
Download from cpan.org and compile and install
#tar -zxvf HTML-Parser-version.gz
# cd HTML-Parser-version
# perl Makefile.pl
# make
# make install
#perl Makefile.PL
1.mail address of admin for whom can send mail about the spam report.
2.network test
3.Checks for all the dependencies of modules. if script exits by any failed dependencies install it.
# make
# make install
Now we can install the init scripts from the source code.
#cd Mail-SpamAssassin-3.2.5/spamd
# ./redhat-rc-script.sh start
Now start the spamd
# spamd -d -c -m5 -H
Its time to install and configure the Mailscanner
MAILSCANNER:
Installation:
mailscanner need not to have clamd or spamassassin running to initialize or run the service.In fact it just need the perl modules that required to start.
Download the source code of the software.
#wget http://www.mailscanner.info/files/4/tar/MailScanner-install-4.75.11-1.tar.gz
#tar -zxvf MailScanner-install-4.75.11-1.tar.gz
# cd MailScanner-install-4.75.11-1
it contains perl modules and install script
#./install.sh
/var/spool/MailScanner
This is a temperory directory userd for processing the msgs.
/var/spool/mqueue.in
port25 sendmail(1) recieves msg -> Place the msg in mqueue.in -> Mailscanner scans and places in mqueue -> sendmail(2) will deliver the msg from mqueue to destination.
Configuring MailScanner:
#cd /opt/MailScanner
This is a symbolic link created by for the installed version of MailScanner.
# cd /opt/MailScanner/etc
This file contains the main configuration of MailScanner.
# vi MailScanner.conf
%org-name% = kiranjith
%org-long-name% = Kiran's School for Linux Lovers
%web-site% = kiranjith83.blogspot.com
Max Children = 5
#by default mailscanner will launch upto 5 process to handle the mails in the mqueue.in. This can be increased according to the msg queue.
Run As User = root
# has to specify the mailscanner to run as.
Queue Scan Interval = 5
# this tells the mailscanner to check the mqueue.in directory in every 5 sec for a new msg.
Incoming Queue Dir = /var/spool/mqueue.in
#This is the directory where the 1st sendmail instance will put the incoming mails for scanning.
Outgoing Queue Dir = /var/spool/mqueue
#This is the directory where the mailscanner will place the scanned mails for 2nd instance of the sendmail to deliver.
Incoming Work Dir = /var/spool/MailScanner/incoming
#This is the directory where mailscanner process the msgs.
Quarantine Dir = /var/spool/MailScanner/quarantine
#In this directory MailScanner places the msgs which is infected by Virus.
Restart Every = 14400
#Every 14400 sec the child process will get restarted
MTA = sendmail
#This specifies the current mta running in the system.
Sendmail = /usr/lib/sendmail
#path to sendmail which used to deliver the error generated on scanning
Max Normal Queue Size = 800
# this tells mailscanner to stop scanning if the mail queue is this much big
#Note:- TNEF Module is needed to scan the content send from MS Outlook.
Virus Scanning = yes
# This enables the virus scanning
Virus Scanners = clamav
#sets the virus scanner to clamav.
Use SpamAssassin = yes
# makes mailscanner to invoke the spamassassin
Always Include SpamAssassin Repot = yes
#this invokes mailscanner to involve the result of spamassassin.
# The SpamAssassin returns a score for the scanned msg and mailscanner will make a decission upon this score. This will invoke both clamav and spamassassin.
Always Include SpamAssassin Report = yes
# This will include the spamassassin repot in the mail header.
/opt/MailScanner/spam.assassin.prefs.conf
/opt/MailScanner/virus.scanners.conf
/opt/MailScanner/mcp
/opt/MailScanner/bin
#./check_mailscanner
#ps -ef |grep -i mailscanner
Sendmail Integrating with MailScanner:
By default the sendmail will be running as MSP as queue directory /var/spool/cilentmqueue and as MTA that binds to the default port of 25.
#/usr/sbin/sendmail -L sm-msp-queue -Ac -q30m
#/usr/sbin/sendmail -L sm-mta -bd -q30m
#kill any existing sendmail deamons
#vim sendmail_startup.sh
#!/bin/bash
sendmail=/usr/sbin/sendmail
#Run the sendmail as MSP program.
$sendmail -L sm-msp-queue -Ac -q30m
#Run the sendmail MTA for inbound (To accept the mail and keep in /var/spool/mqueue.in directory in queueonly mode)
$sendmail -L sm-mta-inbound -bd -OprivacyOptions=noetrn -OdeliveryMode=queueonly -OqueueDirectory=/var/spool/mqueue.in -OPidFile=/var/run/sendmail-in.pid -q30m
#Define the Outbound MTA for delivery msg from /var/spool/mqueue directory,which has been scanned by and placed by MailScanner. The inervel should be short for delivering the mail ASAP.
$sendmail -q1m
Save and execute the script.
#ps -ef |grep sendmail
Check the mail logs
# tail /var/log/maillog
Change Commands That Start Sendmail. Currently, your copy of sendmail will be started by a script such as /etc/init.d/mail or /etc/rc.d/init.d/sendmail. Somewhere in this script will be the command to start sendmail itself. This should look like this:
---------------
sendmail −bd −q15m
--------------
You should change this to the following two lines:
-------------
sendmail −bd -OprivacyOptions=noetrn -OdeliveryMode=queueonly -OqueueDirectory=/var/spool/mqueue.in -OPidFile=/var/run/sendmail-in.pid -q30m
sendmail -q1m
-------------
Note:-
The spamd and clamd deamons are not needed to be running. It is just to ensure the configuration files working or not.
No comments:
Post a Comment
tag ur valuable ideas below