CentOS 7 clamav與spam - 工作雜記

工作雜記

My working blogger,In my daily work log, I meticulously record all the matters and processes I encounter during the day. From the task planning that begins in the morning and the discussions and collaborations with colleagues, to the tools, methods, and processes used in the actual execution of the work, I organize and write them down one by one. Problems encountered during the process, the directions of thought, and the solutions finally found are also clearly recorded in writing

工作雜記

搜尋此網誌

標籤

2016年12月9日 星期五

CentOS 7 clamav與spam



先裝好epel
yum install -y clamav*


/usr/bin/freshclam
若出現
ERROR: Please edit the example config file /etc/freshclam.conf
vi /etc/freshclam.conf
# Comment or remove the line below.
#Example 把這行mark掉


抓出/home底下被感染的檔案
clamscan -r --infected /home


執行全域掃描抓出有問題的檔案,並記錄log檔 (注意:執行時間會很久,若是新機裝好就不必跑了)
clamscan -r -l /var/log/clamscan.log --infected /
若是跑mail主機,/home目錄可能會存放一堆使用者email垃圾感染信,


每天更新病毒碼
20 4 * * * root /usr/bin/freshclam


 


垃圾信的部份:


安裝 perl-Razor-Agent (yum已可以抓到,用yum裝即可)
官網:
http://rpmfind.net/linux/rpm2html/search.php?query=perl-Razor-Agent
CentOS 7 可選Extras Packages for Enterprise Linux 7 for x86_64
wget ftp://rpmfind.net/linux/epel/7/x86_64/p/perl-Razor-Agent-2.85-15.el7.x86_64.rpm
rpm -ivh perl-Razor-Agent-2.85-15.el7.x86_64.rpm
 


安裝 Pyzor (yum已可以抓到,用yum裝即可)
官網下載 http://pyzor.sourceforge.net/


tar jxvf pyzor-0.7.0.tar.bz2
python setup.py build
python setup.py install


若message或maillog一直出現pyzor相關異常(epel0.5.0版本怪怪的,用官網新版的)
mkdir /var/spool/postfix/.pyzor
vi /var/spool/postfix/.pyzor/inform-servers-0-3-x
public.pyzor.org:24441


執行


pyzor discover
pyzor --homedir /etc/mail/spamassassin discover


安裝DCC


下載點 : http://www.dcc-servers.net/dcc/


tar -zxvf dcc.tar.Z
cd dcc-2.3.167
./configure
make
make install


測試DCC


cdcc info


DCC開啟使用:
vi /etc/mail/spamassassin/v310.pre
loadplugin Mail::SpamAssassin::Plugin::DCC (#mark拿掉)


 



vi /etc/mail/spamassassin/local.cf
新增
use_dcc 1
dcc_home /var/dcc 


安裝 spamassassin

yum install spamassassin


local.cf產生器

https://hostineer.com/features/spamassassin-configuration-wizard

貼到/etc/mail/spamassassin/local.cf 的最下面


sa-learn --sync (產生bayes資料庫,先裝好Mailscanner再回頭作)

spamassassin --lint --config-file=/etc/MailScanner/spamassassin.conf -D  (測試設定檔,先裝好Mailscanner再回頭作)


useradd spam (新增使用者不會有Maildir目錄,可用指令mail spam自動產生)
useradd nospam (新增使用者不會有Maildir目錄,可用指令mail nospam自動產生)
sa-learn --prefs-file=/etc/MailScanner/spamassassin.conf --showdots --spam /home/spam/Maildir/new
sa-learn --prefs-file=/etc/MailScanner/spamassassin.conf --showdots --ham /home/nospam/Maildir/new
加入每日排程
vi /etc/crontab 把上面那兩行加進來,記得要加root


垃圾信就寄給spam,正常信寄給nospam
sa-learn --dump magic
可以看到學習的狀況


 


增加SPF記錄:
進入ISP的DNS代管網站
加入一筆MAIL SERVER主機TXT的內容
"v=spf1 a mx ptr ip4:XXX.XXX.XXX.XXX ~all"


 


沒有留言:

張貼留言

Post Top Ad

Your Ad Spot