2016年5月9日 星期一

05/09/2016 pt2

在 CentOS7上安裝設定 E-mail Server(三)

注意事項: 

進階設定流程(一): 
安裝 PostGrey 套件:
#yum -y install postgrey
啟動 PostGrey 服務:
#systemctl enable postgrey.service
#systemctl start postgrey.service
#netstat -anlp | grep postgrey

修改設定檔 /etc/postfix/main.cf:
#vim /etc/postfix/main.cf

#追加、修改下列設定;
smtpd_recipient_restrictions =
permit_mynetworks,
permit_sasl_authenticated,
reject_unknown_sender_domain, ##拒絕來源不明的網域 (限制來源 MTA )
reject_unknown_recipient_domain, ##拒絕不明的收件者 (限制目標 MTA)
reject_unauth_destination, ##拒絕不信任的目標
check_policy_service unix:/var/spool/postfix/postgrey/socket

修改阻擋的秒數:
#vim /etc/sysconfig/postgrey
OPTIONS="--unix=/var/spool/postfix/postgrey/socket --delay=45"

重新啟動 postfix 服務:
#systemctl restart postfix
重新啟動 PostGrey 服務:
#systemctl restart postgrey
可額外設定 PostGrey 白名單
#vim /etc/postfix/postgrey_whitelist_clients
加入可信任的MT郵件主機:
station1.example.com

##設定完成後,請記得重新啟動 PostGrey 服務!


進階設定流程(二): 
修改設定檔 /etc/postfix/main.cf,追加黑名單過濾:
#vim /etc/postfix/main.cf

#追加、修改下列設定;
smtpd_recipient_restrictions =
permit_mynetworks,
permit_sasl_authenticated,
reject_unknown_sender_domain,
reject_unknown_recipient_domain,
reject_unauth_destination,
##以下網址為提供黑名單查詢的網站
reject_rbl_client cbl.abuseat.org,
reject_rbl_client bl.spamcop.net,
reject_rbl_client cblless.anti-spam.org.cn,
reject_rbl_client sbl-xbl.spamhaus.org,
check_policy_service unix:/var/spool/postfix/postgrey/socket

#過濾用戶端是黑名單內的成員:
smtpd_client_restrictions =
check_client_access hash:/etc/postfix/access,
reject_rbl_client cbl.abuseat.org,
reject_rbl_client bl.spamcop.net,
reject_rbl_client cblless.anti-spam.org.cn,
reject_rbl_client sbl-xbl.spamhaus.org

#過濾不明的送件者網域主機
smtpd_sender_restrictions =
reject_non_fqdn_sender,
reject_unknown_sender_domain

重新啟動 postfix 服務:
#systemctl restart postfix

進階設定流程(三): 
修改設定檔 /etc/postfix/main.cf,追加針對郵件內容過濾:
#vim /etc/postfix/main.cf
#追加、修改下列設定:
header_checks = regexp:/etc/postfix/header_checks
body_checks = regexp:/etc/postfix/body_checks

編修/etc/postfix/header_checks、/etc/postfix/body_checks:
#vim /etc/postfix/header_checks
#vim /etc/postfix/body_checks

檔案內的語法:
/規則/ 動作 顯示在登錄檔裡面的訊息

例如:
/^Subject:.*sexy girls/ DISCARD drop header deny

編修完上列兩個檔案後,可進行語言確認:
#postmap -q - regexp:/etc/postfix/body_checks < /etc/postfix/body_checks

沒有留言:

張貼留言