ASSP (Anti-Spam SMTP Proxy) 使用手札 -- Jamyy‘s Weblog

来源:百度文库 编辑:神马文学网 时间:2024/04/29 13:43:48
ASSP (Anti-Spam SMTP Proxy) 使用手札
ASSP 係以 Perl 語言寫成, 是一套開放源碼、跨平台且功能強大的垃圾郵件過濾軟體. 在郵件進入到 MTA (如: Sendmail、Exchange) 前利用 ASSP 過濾病毒、垃圾郵件, 可減輕 Mail Server 的負擔. 由於 ASSP 的強效, 使用前須謹慎調整相關設定, 以免無法收信或誤刪重要郵件.
本篇係以 Fedora Core 3 + Sendmail 環境為主, Windows 環境的建置請參考 ASSP Documentation:ASSP on Win32 - a quick install guide.
配置說明
ASSP 與 Sendmail 安裝在不同電腦上的使用範例: (建議)
Internet

NAT / Firewall (redirect smtp port (TCP 25) to ASSP:25)

ASSP (port: 25, with VirusDB)

Sendmail (port: 25, with MailScanner + ClamAV)

Outlook Express (with SpamPal + AntiVirus Software)
ASSP 與 Sendmail 安裝在同一部電腦上的使用範例:
Internet

NAT / Firewall (redirect smtp port (TCP 25) to ASSP:25)

ASSP (port: 25, with VirusDB)

Sendmail (port: 125, with MailScanner + ClamAV)

Outlook Express (with SpamPal + AntiVirus Software)
Link:圖例說明
ps. SpamPal 請參考:SpamPal Homepage; MailScanner + ClamAV 請參考:Sendmail + MailScanner + ClamAV 安裝實錄
安裝 ASSP
至http://sourceforge.net/project/showfiles.php?group_id=69172 下載 ASSP, 本篇以 1.1.1 版為例
cd /opt
wget http://nchc.dl.sourceforge.net/sourceforge/assp/assp-1.1.1.zip
unzip assp-1.1.1.zip -d ./assp
cd assp
chmod a+x freshclam.sh
./freshclam.sh
perl assp.pl (產生 assp.cfg)
Ctrl + C
vi assp.cfg
將 allowAdminConnectionsFrom:= 改成如下:
allowAdminConnectionsFrom:=127.0.0.1|192.168. (讓 LAN 可以連入管理)
perl assp.pl
開啟瀏覽器, 連結 http://assp.host.ip.addr:55555
預設密碼: nospam4me
修改設定
主選單 項目 assp.cfg 對應參數 修改值
Network Setup SMTP Destination smtpDestination 填入 Mail Server IP 與埠號. 如: 192.168.1.1:25 或 127.0.0.1:125
Listen Port listenPort 25
As a Daemon AsADaemon 1 (勾選)
Whitelist Whitelisted Domains* whiteListedDomains 允許寄入的 domain name
Relaying Accept All Mail* acceptAllMail 允許寄入的 mail server ip
Local Domains* localDomains 填入本地 domain name
Validate Recipients Do LDAP lookup for valid recipients DoLDAP 清除值 (取消勾選)
Security Web Admin Password webAdminPassword 變更 web 管理密碼
ps. 標註 " * " 的欄位表示可以填入多個值, 以 " | " 符號 (前後無空格) 隔開
安裝相關 Perl 模組 (Optional)
cpan
Are you ready for manual configuration? [yes] ==> no
cpan> install Email::Valid
cpan> install Mail::Address
cpan> install Net::DNS
cpan> install Net::Domain::TLD
ps. 亦可至 http://search.cpan.org/ 自行下載、安裝相關模組, 安裝方式為: 解包 → perl Makefile.PL && make && make install
變更 sendmail 使用 port
vi /etc/mail/sendmail.mc
將 DAEMON_OPTIONS(‘Port=smtp,Addr=0.0.0.0, Name=MTA‘) 改成
DAEMON_OPTIONS(‘Port=125,Addr=0.0.0.0, Name=MTA‘)
m4 sendmail.mc > sendmail.cf
service sendmail restart
允許 ASSP Host Relay
當 ASSP Host 與 Mail Server 不在同一部電腦時, 須在 Mail Server 設定允許 ASSP Host 的 Relay. 以 Sendmail 為例:
cd /etc/mail
vi access
127.0.0.1  Relay
 Relay
makemap hash access < access
建立 spam 資料庫
剛開始運行 ASSP 的前幾天, 建議以 Test Mode 來運作, 目的是避免 ASSP 誤刪正式郵件, 並且蒐集 spam mail 來建立 spam 資料庫.
在蒐集大量的 spam 郵件, 並且確定 spam 資料夾裡的郵件都是垃圾信後, 執行: perl rebuildspamdb.pl 即可建立 spam 資料庫
執行完 rebuildspamdb 後即可清除 spam / notspam 郵件檔
cd /opt/assp/spam
rm -rf -- *
cd ../notspam
rm -rf -- *
ps. "-" 開頭的檔名要加 "--" 參數才能處理
由於中文郵件主旨存成的檔名都是亂碼, 以主旨來當檔名沒啥意義,
可取消勾選 SPAM Control 選單裡的 Use Subject as Maillog Names (assp.cfg => UseSubjectsAsMaillogNames)
則存在 spam / notspam 裡的郵件檔案會以流水號為檔名
以上動作可排程處理: 每週或每半個月執行一次 (間隔時間越長, 蒐集到的 spam mail 越完整, 但是 rebuild 資料庫的時間也越長)
另外要排程處裡的是 freshclam.sh 讓系統自動更新病毒資料庫
/etc/crontab:
0 0 * * 0 root cd /opt/assp; ./rebuildspamdb.sh (每週日凌晨重建 spamdb)
0 */3 * * * root cd /opt/assp; ./freshclam.sh (每三小時執行一次 freshclam.sh, 若病毒資料庫有更新就下載)
rebuildspamdb.sh:
#!/bin/bash
cd /opt/assp
/usr/bin/perl rebuildspamdb.pl
rm -rf -- ./spam/*
rm -rf -- ./notspam/*
從 /opt/assp/maillog.txt 觀察 ASSP 的運作 (執行 tail -f maillog.txt 或 less +F maillog.txt 持續監控 log 訊息), 當一切妥當時即可取消 Test Mode (在 TestMode Options 中取消勾選所有 Test Mode 項目)
取消 Test Mode 後若有誤刪正式郵件的情況, 可從 Whitelist Options 或 Relaying 選單中變更相關設定
以上是小弟我個人的使用備忘, 如有錯誤敬請不吝指正, 謝謝!
參考資料:
ASSP DocumentationUsing ASSP to Filter SpamHow can I stop spammers!!!??Perl 學習手札windtear 追求完美: Anti-Spam-SMTP-Proxy (ASSP) assp 1.1.1 自己維護 clamav 更新
本站相關文章:
Sendmail + MailScanner + ClamAV 安裝實錄Fedora Core Sendmail 開放遠端收發信件
Posted by Jamyy at 2005年10月15日 12:00
from: http://cha.homeip.net/blog/archives/2005/10/assp_antispam_s.html#more