2019/10/05

最近把mail server升到 centos 8
可是
預設卻找不到 postgrey
XD

只好手動來了
首先到 https://postgrey.schweikert.ch/ 下載
直接解開就可以用了 不用編譯
只是要補一些東西

dnf install -y perl-NetAddr-IP perl-Net-Server perl-BerkeleyDB

groupadd nogroup
adduser postgrey

mkdir /var/spool/postfix/postgrey
touch /var/spool/postfix/postgrey/socket
chown -R postgrey.nogroup /var/spool/postfix/postgrey

cd /etc/postfix

下載官方白名單
wget https://postgrey.schweikert.ch/pub/postgrey_whitelist_clients

再產生一個 /etc/postfix/postgrey_whitelist_recipients 視需要修改內容

啟動postgrey

./postgrey --unix=/var/spool/postfix/postgrey/socket --delay=60 -d

記得加入 /etc/rc.local開几執行

修改 /etc/postfix/main.cf

在原來的
smtpd_recipient_restrictions =
加上
   check_policy_service unix:/var/spool/postfix/postgrey/socket

重啟postfix
systemctl restart postfix

接下來看看/var/log/maillog 有沒有類似以下的訊息
如果有
就表示ok了

Oct  5 11:21:57 mail postfix/smtpd[10103]: NOQUEUE: reject: RCPT from nedm.ubot.com.tw[125.227.165.70]: 450 4.2.0 <abc@test.com>: Recipient address rejected: Greylisted, see http://postgrey.schweikert.ch/help/mail.nkuht.edu.tw.html; from=<UBOT@nedm.ubot.com.tw> to=<shangpao@mail.nkuht.edu.tw> proto=ESMTP helo=<nedm.ubot.com.tw>

postgrey有一個報表工具 postgreyreport
如果要使用要再補上

dnf install -y perl-Net-DNS

指令如下

Depending on how busy your server is, the report can get quite large. To get only the top 20 sources getting greylisted out - you can use something like this :

cat /var/log/maillog | postgreyreport | awk '{print $1}' | sort | uniq -c | sort -nr | head -n20

To get a list of the top 20 email address that the greylisted sources are sending email to :

cat /var/log/maillog | postgreyreport | awk '{print $4}'  | sort  | uniq -c | sort -nr | head -n20


https://wiki.centos.org/HowTos/postgrey#head-70ed10e62fb7da94deb39a987e1e4e205c2ae2c5

沒有留言: