Monday, March 31, 2014

Centos 6.5 Thiết lập MailScanner, Clam Antivirus và SpamAssasin


Chuẩn bị hệ thống
  • Disabled SElinux trong Centos
[root@localhost ~]# vi /etc/sysconfig/selinux
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
#     targeted - Targeted processes are protected,
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted
  • Add reqpository trong Centos
Xem  version Centos
[root@localhost ~]# cat /etc/redhat-release
CentOS release 6.5 (Final)
Xem Centos 32bit hay 64 bit
[root@localhost ~]# uname -a
Linux localhost.localdomain 2.6.32-431.5.1.el6.x86_64 #1 SMP Wed Feb 12 00:41:43 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

Cài đặt RPMforge trong Centos
Cho 64-bit CentOS 6.*:
#rpm -Uvh http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
Cài đặt các gói Dependencies
# yum install gcc cpp perl bzip2 zip unrar make patch automake rpm-build perl-DBI perl-MIME-tools perl-DBD-SQLite binutils glibc-devel perl-Filesys-Df zlib zlib-devel
Cài đặt ClamAV và SpamAssassin 
#yum install clamav spamassassin 
update ClamAV
# freshclam -v
Update và start SpamAssassin
# sa-update
# service spamassassin start
# chkconfig spamassassin on
Fix path MailScanner bằng cách tạo symbolic link
# ln -s /usr/bin/freshclam /usr/local/bin/freshclam 

Cấu hình Postfix
# service postfix stop
# chkconfig postfix off 
Postfix header_checks giữ bất kỳ incoming email mà postfix nhận.
# vi /etc/postfix/main.cf 
## This line is added ##
header_checks = regexp:/etc/postfix/header_checks

#vi /etc/postfix/header_checks 
## This line is added ##
/^Received:/ HOLD

Chuẩn bị MailScanner
MailScanner không có sẵn trong Centos hay Repoforge repositories.
# wget http://www.mailscanner.info/files/4/rpm/MailScanner-4.84.6-1.rpm.tar.gz
# tar zxvf MailScanner-4.84.6-1.rpm.tar.gz
# cd MailScanner-4.84.6-1# ./install.sh 
Cài đặt thư mục cần thiết cho SpamAssassin thay đổi permissions
# mkdir /var/spool/MailScanner/spamassassin
# chown postfix /var/spool/MailScanner/spamassassin
# chown postfix /var/spool/MailScanner/incoming/* 
Cấu hình file MailScanner backup
# vi /etc/MailScanner/MailScanner.conf 
%org-name% = test CentOS Mail Server
%org-long-name% = ORGFULLNAME
%web-site% = ORG WEBSITE
Run As User = postfix
Run As Group = postfix
MTA = postfix
Incoming Queue Dir = /var/spool/postfix/hold
Outgoing Queue Dir = /var/spool/postfix/incoming
Virus Scanners = clamav
## please check /etc/MailScanner/spam.lists.conf for more details ##
Spam List = SBL+XBL
## the directory created earlier ##
SpamAssassin User State Dir = /var/spool/MailScanner/spamassassin
Tại thời điểm này,MailScanner đã có sẵn

Debug MailScanner
# MailScanner -lint 
# service MailScanner start
# chkconfig MailScanner on

Kiểm tra hoạt động MailScanner
# tailf /var/log/maillog

No comments:

Post a Comment