CentOS VPS安装Fail2ban

Fail2ban是用于防止主机口令被暴力破解的一个Linux系统下的工具。我在VPS上用lastb命令看了下,只见屏幕刷了好长时间,一直有人在扫弱口令,把IP一个个手工添加到iptables阻止连接ssh太麻烦,用这个工具自动过滤。

1、CentOS安装Fail2ban要先安装EPEL源:

rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
yum install fail2ban

2、fail2ban基本的工作原理
fail2ban → 监视相应的log → 连续出现多次错误信息 → 封锁IP(使用iptables)→ 根据设定间隔时间,自动清除iptables规则。fail2ban的配置文件在/etc/fail2ban目录内。

/etc/fail2ban/fail2ban.conf fail2ban本身设置
/etc/fail2ban/jail.conf fail2ban全局设置
/etc/fail2ban/filter.d/ 内为fail2ban的正则表达式过滤规则
/etc/fail2ban/action.d/ 内为fail2ban触发后行动的脚本
继续阅读CentOS VPS安装Fail2ban