[教學] Postgrey

postgrey是一套擋廣告信的軟體,當有信寄到該主機時,會先騙寄信的主機稍後再寄一次,正常的主機都會等候一段時間重送,若是發廣告信的軟體,為了效率通常不會有重送機制

1.安裝相關套件
Net-Server-0.97
IO-Multiplex-1.09
BerkeleyDB-0.34(perl)

# perl Makefile.PL
# make
# make install

2. 安裝Berkeley DB
Berkeley DB(db-4.4.20)
# cd build_unix/
# ../dist/configure
# make
# make install


3.安裝Postgrey
# tar -zxvf postgrey-1.27.tar.gz
# cd postgrey-1.27
將postgery執行檔放置/usr/local/sbin
# cp postgrey /usr/local/sbin

建立postgery目錄
# mkdir /var/spool/postfix/postgrey
變更目錄所屬者
# chown postfix:postfix /var/spool/postfix/postgrey
覆制白名單至 /etc/postfix/
# cp postgrey_whitelist_clients postgrey_whitelist_recipients /etc/postfix/

4.修改postfix設定檔
# vi /etc/postfix/main.cf
修改 smtpd_recipient_restrictions 如下的內容:
smtpd_recipient_restrictions =permit_mynetworks, reject_unauth_destination, check_policy_service inet:127.0.0.1:10023

5.設定開機自動執行
方法1:

# vi /etc/rc.d/rc.local
新增如下的內容:
/usr/local/sbin/postgrey –inet=10023 –user=postfix –group=postfix -d

方法2:
寫一隻shell script 來控制
# vi postgrey.init

內容如下
#!/bin/bash

# chkconfig: 2345 36 36
# description: Postgrey Script

start() {
echo -n "Starting Postgrey: "
/usr/local/sbin/postgrey –inet=10023 –user=postfix –group=postfix –delay=60 -d
return 0
}
stop() {
killall postgrey
return 0
}
case "$1″ in
start)
start
;;
stop)
stop
;;
esac

將postgrey加入 chkconfig 並啟動
# cp postgrey.init /etc/rc.d/init.d/postgrey
# chkconfig –add /etc/rc.d/init.d/postgrey
# service postgrey start

查看是否有啟動成功
# ps aux | grep postgrey
如有下列這訊息表示postgrey 正在運作中
postfix   1505  0.0  1.5  13220  8092 ?        Ss   16:19   0:00 /usr/local/sbin/postgrey –inet=10023 –user=postfix –group=postfix –delay=60 -d

6.由maillog檢驗Postgrey是否運作正常
# tail /var/log/maillog
如有類似下面這訊息表示成功
Mar 31 22:28:27 centos postfix/smtpd[601]: NOQUEUE: reject: RCPT from n2d.bullet.mail.tp2.yahoo.com[203.188.202.140]: 450 4.2.0 <shian@msa.shian.tw>: Recipient address rejected: Greylisted, see http://postgrey.schweikert.ch/help/msa.shian.tw.html; from=<thomas0745@yahoo.com.tw> to=<shian@msa.shian.tw> proto=SMTP helo=<n2d.bullet.mail.tp2.yahoo.com>

Related Posts with Thumbnails

相關文章

2 thoughts on “[教學] Postgrey

  1. 因為我是用centos5 yum 沒有Postgrey這套件可以安裝,所以去官網抓下來自己編譯安裝,網路上這套件的rpm得找找看有無人打包好,不過相依性也會是個問題,因為它需要其它相關套件,如果有時間機會的話我再去找找看~

發表迴響

您的電子郵件位址並不會被公開。 必要欄位標記為 *

*

您可以使用這些 HTML 標籤與屬性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>