postgrey是一政策伺服器,用來過濾Postfix伺服器上的垃圾郵件,
利用垃圾郵件伺服器寄出信件後不理會的特性,postgrey先回應450的錯誤,
等待發信郵件伺服器嘗試再次連線寄件過來時,將此郵件伺服器列入白名單資料庫,
用以判斷是否為垃圾郵件。
1.安裝
[root@dns etc]# yum -y install postgrey
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* Webmin: download.webmin.com
* base: ftp.tc.edu.tw
* elrepo: repos.lax-noc.com
* epel: mirror.nus.edu.sg
* extras: ftp.tc.edu.tw
* rpmforge: mirror.oscc.org.my
* updates: ftp.tc.edu.tw
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package postgrey.noarch 0:1.34-1.el6.rf will be installed
--> Processing Dependency: perl(Net::Server) for package: postgrey-1.34-1.el6.rf.noarch
--> Processing Dependency: perl(Net::Server::Multiplex) for package: postgrey-1.34-1.el6.rf.noarch
--> Processing Dependency: perl(IO::Multiplex) for package: postgrey-1.34-1.el6.rf.noarch
--> Processing Dependency: perl(Net::Server::Daemonize) for package: postgrey-1.34-1.el6.rf.noarch
--> Processing Dependency: perl(Parse::Syslog) for package: postgrey-1.34-1.el6.rf.noarch
--> Running transaction check
---> Package perl-IO-Multiplex.noarch 0:1.13-1.el6.rf will be installed
---> Package perl-Net-Server.noarch 0:0.99-1.el6.rf will be installed
---> Package perl-Parse-Syslog.noarch 0:1.10-1.el6.rf will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=======================================================================================================================
Package Arch Version Repository Size
=======================================================================================================================
Installing:
postgrey noarch 1.34-1.el6.rf rpmforge 46 k
Installing for dependencies:
perl-IO-Multiplex noarch 1.13-1.el6.rf rpmforge 23 k
perl-Net-Server noarch 0.99-1.el6.rf rpmforge 171 k
perl-Parse-Syslog noarch 1.10-1.el6.rf rpmforge 15 k
Transaction Summary
=======================================================================================================================
Install 4 Package(s)
Total download size: 255 k
Installed size: 579 k
Downloading Packages:
(1/4): perl-IO-Multiplex-1.13-1.el6.rf.noarch.rpm | 23 kB 00:00
(2/4): perl-Net-Server-0.99-1.el6.rf.noarch.rpm | 171 kB 00:02
(3/4): perl-Parse-Syslog-1.10-1.el6.rf.noarch.rpm | 15 kB 00:00
(4/4): postgrey-1.34-1.el6.rf.noarch.rpm | 46 kB 00:00
-----------------------------------------------------------------------------------------------------------------------
Total 61 kB/s | 255 kB 00:04
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : perl-IO-Multiplex-1.13-1.el6.rf.noarch 1/4
Installing : perl-Parse-Syslog-1.10-1.el6.rf.noarch 2/4
Installing : perl-Net-Server-0.99-1.el6.rf.noarch 3/4
Installing : postgrey-1.34-1.el6.rf.noarch 4/4
Verifying : perl-Net-Server-0.99-1.el6.rf.noarch 1/4
Verifying : postgrey-1.34-1.el6.rf.noarch 2/4
Verifying : perl-Parse-Syslog-1.10-1.el6.rf.noarch 3/4
Verifying : perl-IO-Multiplex-1.13-1.el6.rf.noarch 4/4
Installed:
postgrey.noarch 0:1.34-1.el6.rf
Dependency Installed:
perl-IO-Multiplex.noarch 0:1.13-1.el6.rf perl-Net-Server.noarch 0:0.99-1.el6.rf
perl-Parse-Syslog.noarch 0:1.10-1.el6.rf
Complete!
[root@dns etc]#
2.設定/etc/postfix/main.cf
新增或修改參數smtpd_recipient_restrictions
例如:
smtpd_recipient_restrictions = permit_mynetworks,reject_non_fqdn_recipient,reject_unknown_recipient_domain,permit_sasl_authenticated,
reject_unauth_destination,reject,check_policy_service unix:postgrey/socket
3.建立postgrey設定檔
設定初次拒絕郵件伺服器時間為60秒
vi /etc/sysconfig/postgrey
OPTIONS="--unix=/var/spool/postfix/postgrey/socket --delay=60"
4. 啟動postgrey
service postgrey start
5.設定開機自動啟動
chkconfig postgrey on
6.重啟動postfix
service postfix restart
7.觀察/var/log/maillog
有類似下列訊息,代表postgrey已整合到postfix
Nov 28 11:27:16 dns postgrey[10178]: Process Backgrounded
Nov 28 11:27:16 dns postgrey[10178]: 2013/11/28-11:27:16 postgrey (type Net::Server::Multiplex) starting! pid(10178)
Nov 28 11:27:16 dns postgrey[10178]: Binding to UNIX socket file "/var/spool/postfix/postgrey/socket"
Nov 28 11:27:16 dns postgrey[10178]: Setting gid to "487 487"
Nov 28 11:27:16 dns postgrey[10178]: Setting uid to "493"
8.定義自己內部主機的白名單
postgrey會在/etc/postfix/下產生三個白名單檔案
postgrey_whitelist_clients
postgrey_whitelist_recipients
postgrey_whitelist_clients.local
設定自己信任的寄件來源
vi /etc/postfix/postgrey_whitelist_clients.local
加上
192.168.2.1
60.250.xx.oo
example.com.tw
參考資料:
留言列表