防ssh及vsftpd暴力破解实例
建立/etc/fail2ban/jail.local文件,在文件中加入:
[vsftpd-iptables]
enabled = true
filter = vsftpd
action = iptables[name=VSFTPD, port=ftp, protocol=tcp]
sendmail-whois[name=VSFTPD, dest=you@mail.com]
logpath = /var/log/secure
maxretry = 3
[ssh-iptables]
enabled = true
filter = sshd
action = iptables[name=SSH, port=ssh, protocol=tcp]
sendmail-whois[name=SSH, dest=you@example.com, sender=fail2ban@example.com]
logpath = /var/log/secure.log
maxretry = 5
enabled:可选值false,true
filter:指定/etc/fail2ban/filter.d/目录下的正则文件,如filter = sshd则是指定/etc/fail2ban/filter.d/sshd.conf。
action:指定执行的动作,具体动作文件在/etc/fail2ban/action.d目录下。
logpath:指定监控日志的路径。
maxretry:执行action匹配的次数。
接着执行:
service iptables start
service fail2ban start
可以 用fail2ban 分析freeswitch log文件,当发现注册攻击时 启用防火墙规则拒绝此ip的请求。
