fail2ban協助postfix過濾惡意IP

來源:互聯網
上載者:User

fail2ban協助postfix過濾惡意IP 今天看postfix 日誌,發現日誌中報大量的NOQUEUE: reject: RCPT from unknown[183.60.103.208]: 504 5.5.2 ,而且在不停的換IP,頻率很高,一分鐘能收到2000左右的串連,雖然postfix 已經拒絕了請求,但是這也很浪費伺服器資源。決定扼殺在萌芽狀態。於是想起了fail2ban。 首先安裝,yum 安裝,需要epel 源 yum install fail2ban -y cd /etc/fail2ban vi jail.conf #[postfix-tcpwrapper][POSTFIX]enabled  = tureport = smtpfilter   = postfixlogpath  = /var/log/zimbra.log ##日誌action   =iptables[name=Postfix, port=25, protocol=tcp] ##調用iptables 拒絕ipignoreip = 127.0.0.1 192.168.2.0/16 ##忽略的ip地址,或者是信任的ip地址bantime  = 86400 #####禁止其訪問的時間(秒)findtime = 60 maxretry = 5 ###最大嘗試次數 vi filter.d/postfix.conf                 failregex = warning: (.*)\[<HOST>\]: SASL LOGIN authentication failed:             reject: RCPT from (.*)\[<HOST>\]: 550 5.1.1             reject: RCPT from (.*)\[<HOST>\]: 450 4.7.1             reject: RCPT from (.*)\[<HOST>\]: 554 5.7.1             reject: RCPT from (.*)\[<HOST>\]: 554 5.5.2              reject: RCPT from (.*)\[<HOST>\]: 504 5.5.2###過濾規則,上面4條預設有,我另外加了兩條 然後啟動服務:service fail2ban start 查看狀態:  fail2ban-client status POSTFIXStatus for the jail: POSTFIX|- filter|  |- File list:        /var/log/zimbra.log |  |- Currently failed: 0|  `- Total failed:     8`- action   |- Currently banned: 1   |  `- IP list:       120.197.131.6    `- Total banned:     1 已經有IP地址了 iptables -L Chain fail2ban-Postfix (1 references)target     prot opt source               destination         DROP       all  --  120.197.131.6        anywhere            RETURN     all  --  anywhere             anywhere   世界終於安靜多了 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.