Amavis & Clamd Installation

                                                                    
                                            
        Install amavis
1. install perl*
[root@mail ~]#  yum install perl

2. install cpan
[root@mail ~]# perl -MCPAN -e shell

3. login cpan
[root@mail ~]# cpan ==> enter
example

[root@test ~]# cpan
Terminal does not support AddHistory.

cpan shell --CPAN exploration and modules installation (v1.7602)
ReadLine support available (try 'install Bundle::CPAN')

cpan> install Compress::Raw::Zlib

######## Modeuls ##############
Compress::Raw::Zlib
IO::Compress::Base
IO::Compress::Zlib
Compress::Zlib
IO::Zlib
Algorithm::Diff
Text::Diff
Archive::Tar
File::Which
Archive::Zip
BerkeleyDB
IO::stringy
MailTools
MIME::Base
MIME::tools
Convert::TNEF
Convert::BinHex
Convert::UUlib
Data::UUID
Digest::MD5
Net::Server
Time::HiRes
zlib
Unix::Syslog
Sys::Hostname::Long
Socket
IP::Country
Net::CIDR::Lite
Net_SSLeay.pm
IO::Socket::SSL
Net::Ident
Mail::SPF::Query
razor::agents
razor::agents::sdk
Mail::SpamAssassin
######################################
==> To install AMAVISD :
Commands (as root) -
[root@mail ~]# mkdir /var/amavis
[root@mail ~]# groupadd vscan
[root@mail ~]# useradd -g vscan -d /var/amavis  -s /bin/bash vscan
[root@mail ~]# chmod 750 /var/amavis
[root@mail ~]# mkdir /var/amavis/tmp

(Download amavisd)
URL :- ==> http://www.ijs.si/software/amavisd/amavisd-new-2.7.1.tar.gz

[root@mail ~]# tar -zxvf amavisd-new-2.7.1.tar.gz
[root@mail ~]# cd amavisd-new-2.7.1
[root@mail ~]# cp amavisd /usr/sbin
[root@mail ~]# chown root /usr/sbin/amavisd
[root@mail ~]# chmod 755 /usr/sbin/amavisd
[root@mail ~]# cp amavisd.conf /etc
[root@mail ~]# chown root /etc/amavisd.conf
[root@mail ~]# chmod 644 /etc/amavisd.conf
[root@mail ~]# mkdir /var/virusmails
[root@mail ~]# chmod 750 /var/virusmails/
[root@mail ~]# chown vscan /var/virusmails/
[root@mail ~]# mkdir /var/amavis/db
[root@mail ~]# chown -R vscan:vscan /var/amavis
Now edit /etc/amavisd.conf by command ->

[root@mail ~]# vi /etc/amavisd.conf
Edit the lines to become -
$mydomain = 'example.com';
$virus_admin      = "security\@$mydomain";
$mailfrom_notify_admin     = "security\@$mydomain";
$mailfrom_notify_recip     = "security\@$mydomain";
$mailfrom_notify_spamadmin = "security\@$mydomain";
and Uncomment the following (remove # in front & give /tmp/clamd.socket on
this line)-
['ClamAV-clamd',
   \&ask_daemon, ["CONTSCAN {}\n", " /tmp/clamd.socket "],
   qr/\bOK$/, qr/\bFOUND$/,
   qr/^.*?: (?!Infected Archive)(.*) FOUND$/ ],
save and quit
AMAVISD INSTALL OVER
=======> START CLAMAV INSTALLATION <==========
Commands (as root) -

[root@mail ~]# groupadd clamav
[root@mail ~]# useradd -g clamav -s /bin/false -c "Clam Antivirus" clamav

URL :- ===> http://downloads.sourceforge.net/project/clamav/clamav/0.97.4/clamav-0.97.4.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fclamav%2Ffiles%2Fclamav%2F0.97.4%2F&ts=1337755989&use_mirror=nchc
(Download clamav) :  clamav-0.97.4.tar.gz

[root@mail ~]# tar -zxvf clamav-0.97.4.tar.gz
[root@mail ~]# cd clamav-0.97.4
[root@mail ~]# ./configure --sysconfdir=/etc
[root@mail ~]# make
[root@mail ~]# make install
[root@mail ~]#mkdir /var/lib/clamav
[root@mail ~]#chown – R clamav:clamav /var/lib/clamav

Now edit /etc/clamd.conf by command ->
[root@mail ~]# cd /etc
[root@mail ~]# cp clamd.conf clamd.conf_org
[root@mail ~]# vi clamd.conf
Edit the lines to become -
#Example       {Put # in fronf of Example line}
LogFile /tmp/clamd.log                    {Remove # in front of  line}
DatabaseDirectory /var/lib/clamav      {Remove # in front of line}
save and quit

Now edit  /etc/freshclam.conf by command ->
[root@mail ~]# cp freshclam.conf freshclam.conf_org

[root@mail ~]# vi freshclam.conf
Edit the lines to become -
#Example                     {Put # in fronf of Example line}
save and quit
[root@mail ~]# touch /var/log/clam-update.log
[root@mail ~]# chmod 600 /var/log/clam-update.log
[root@mail ~]# chown clamav /var/log/clam-update.log
[root@mail ~]# /usr/local/bin/freshclam --datadir=/var/lib/clamav -l
/var/log/clam-update.log

Edit crontab by command ->
[root@mail ~]# crontab -e
Add line ->
06 08 * * * /usr/local/bin/freshclam --quiet -l /var/log/clam-update.log
save and quit
CLAM AV INSTALLATION OVER
Test CLAMAV by command
[root@mail ~]# /usr/local/sbin/clamd
(Should not give error)
Test AMAVISD by command -
/usr/sbin/amavisd
(Should not give error)

[root@mail~]# sa-upbate


Edit this file to autostart antivirus
[root@mail ~]# vi /etc/rc.d/rc.local
Edit  in the last :
/usr/local/sbin/clamd
/usr/sbin/amavisd
[root@mail ~]# cd /etc/postfix
To add Amavisd and Clam to Postix, edit master.cf and add the following lines
[root@mail ~]# cp master.cf master.cf_org

[root@mail ~]# vi master.cf
smtp-amavis unix -      -       n       -       2  lmtp
    -o lmtp_data_done_timeout=1200
    -o lmtp_send_xforward_command=yes
127.0.0.1:10025 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=127.0.0.0/8
    -o strict_rfc821_envelopes=yes
    -o smtpd_error_sleep_time=0
    -o smtpd_soft_error_limit=1001
    -o smtpd_hard_error_limit=1000
save and quit

Edit main.cf and add -
[root@mail ~]# vim /etc/postfix/main.cf
content_filter=smtp-amavis:[127.0.0.1]:10024
save and quit

[root@mail~]# /etc/init.d/postfix restart

To check if anti-virus is running
[root@mail~]# ps -ef  | grep clamd
[root@mail~]# ps -ef | grep amavisd

[root@mail~]# telnet localhost 10024
rying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
220 [127.0.0.1] ESMTP amavisd-new service ready

[root@mail~]# telnet localhost 10025
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
220 a.raju.com ESMTP Postfix



Comments

Popular posts from this blog

How to install and configure node js and PM2 in rhel7

PCS Corosync Pacemaker Cluster Mariadb using NFS

How to Create or Configure iSCSI Server and Clinet