EMOS-fail2banweb
用戶擔憂,本身的郵件帳號被外部經過字典***怎麼辦,fail2ban是一個很是優秀的工具。fail2ban能夠監視系統日誌,而後匹配日誌的錯誤信息(正則式匹配)執行相應的屏蔽動做(通常狀況下是調用防火牆屏蔽,也能夠發送e-mail通知系統管理員),如:當有人在試探你的SSH、SMTP、POP3、webmail密碼,只要達到你預設的次數,fail2ban就會調用防火牆屏蔽這個IP。ssh
在日誌中,發如今許多sasl login的報錯日誌,有嘗試盜用帳號發郵件的狀況,tcp
Nov 17 04:10:35 mail postfix/smtpd[13618]: warning: unknown[199.36.76.15]: SASL LOGIN authentication failed: authentication failureide
Nov 17 04:10:36 mail postfix/smtpd[13618]: warning: unknown[199.36.76.15]: SASL LOGIN authentication failed: authentication failure工具
Nov 17 04:10:37 mail postfix/smtpd[13618]: warning: unknown[199.36.76.15]: SASL LOGIN authentication failed: authentication failurepost
Nov 17 04:10:38 mail postfix/smtpd[13618]: warning: unknown[199.36.76.15]: SASL LOGIN authentication failed: authentication failurespa
默認狀況下,fail2ban工具是能pop3,webmail,sshd作阻擋,對sasl阻攔無效,須要修改sasl.conf文件日誌
編輯/etc/fail2ban/jail.conf,增長ip
[sasl]get
enabled = true
filter = sasl
action = iptables[name=sasl, port=25, protocol=tcp]
logpath = /var/log/maillog
bantime = 1200 #阻擋20分鐘
findtime = 120 #在2分鐘內嘗試15次就被阻擋
maxretry = 15
修改/etc/fail2ban/filter.d/sasl.conf,
註釋下行:
#failregex = : warning: [-._\w]+\[<HOST>\]: SASL (?:LOGIN|PLAIN|(?:CRAM|DIGEST)-MD5)authentication failed$
failregex = : warning: unknown\[<HOST>\]: SASL LOGIN authentication failed: authentication failure
重啓fail2ban服務,查看日誌已生效
運行 iptables -L,顯示以下,說明對sasl已生效
Chain fail2ban-sasl (1 references)
target prot opt source destination
DROP all -- 121.239.157.15 anywhere
DROP all -- 180.107.119.250 anywhere
RETURN all -- anywhere anywhere