fail2ban配置postfix
首先到www.fail2ban.org下载fail2ban
通过wget --no-check-certificate https://github.com/fail2ban/fail2ban/archive/0.8.14.tar.gz
解压并确认python版本,通过python -V查询
通过README.md得知,通过python setup.py install安装
通过grep chkconfig ./* -R --color 查看启动文件,然后 cp files/redhat-initd /etc/init.d/fail2ban
chkconfig --add fail2ban 添加启动服务
编辑/etc/fail2ban/jail.conf,添加如下配置:
[postfix-ddos] enabled = true filter = postfix-ddos action = iptables-allports[name=MAIL, protocol=all] logpath = /var/log/maillog maxretry = 2 findtime = 86400 bantime = 604800
8.然后在/etc/fail2ban/filter.d中,创建一个文件,命名为postfix-ddos.conf,添加如下内容:
# Fail2Ban filter for Postfix DDOS attacks # [INCLUDES] before = common.conf [Definition] _daemon = postfix/(submission/)?smtp(d|s) failregex = ^%(__prefix_line)sNOQUEUE: reject: RCPT from \S+\[<HOST>\]: 450 4\.7\.1 Client host rejected: cannot find your hostname, (\[\S*\]); from=<\S*> to=<\S+> proto=ESMTP helo=<\S*>$ ^%(__prefix_line)sNOQUEUE: reject: RCPT from \S+\[<HOST>\]: 450 4\.7\.1 : Helo command rejected: Host not found; from=<> to=<> proto=ESMTP helo= *$ ^%(__prefix_line)sNOQUEUE: reject: RCPT from \S+\[<HOST>\]: 454 4\.7\.1 Service unavailable; Client host \[\S+\] blocked using .* from=<\S*> to=<\S+> proto=ESMTP helo=<\S*>$ ^%(__prefix_line)sNOQUEUE: reject: VRFY from \S+\[<HOST>\]: 550 5\.1\.1 .*$ ^%(__prefix_line)sNOQUEUE: reject: RCPT from \S+\[<HOST>\]: 504 5\.5\.2 .*$ ^%(__prefix_line)sNOQUEUE: reject: RCPT from \S+\[<HOST>\]: 554 5\.7\.1 .*$ ^%(__prefix_line)simproper command pipelining after \S+ from [^[]*\[<HOST>\]:?$ ^%(__prefix_line)slost connection after \S+ from [^[]*\[<HOST>\]:?$ ^%(__prefix_line)swarning: [-._\w]+\[<HOST>\]: SASL ((?i)LOGIN|PLAIN|(?:CRAM|DIGEST)-MD5) authentication failed(: [ A-Za-z0-9+/:]*={0,2})?\s*$ ^%(__prefix_line)sstatistics: max connection rate \S+ for \(smtp:<HOST>\):?$ ignoreregex = lost connection after .* from unknown\[unknown\]$ authentication failed: Connection lost to authentication server$ statistics: max connection rate .* for \(smtp:unknown\).*$ [Init] journalmatch = _SYSTEMD_UNIT=postfix.service
10.启动服务/etc/init.d/fail2ban start 可以通过fail2ban-client status postfix-ddos查看状态
<< 上一篇
下一篇 >>
网友留言(0 条)