Fail2ban什么? 百度下就知道是做什么的了!
1、官网下载地址:https://github.com/fail2ban/fail2ban/releases
fail2ban-0.9.6.tar.gz 0.9.6的版本
2、解压后安装:
3、修改配置文件开启asterisk。
[root@pbx fail2ban]# vim /etc/fail2ban/jail.conf
点击( 此处 )折叠或打开
4、修改iptables动作的参数去掉“-w”(和防火墙版本有关),找到参数 lockingopt
[root@pbx fail2ban]# vim /etc/fail2ban/action.d/iptables-common.conf
5、启动fail2ban 服务:
[root@pbx fail2ban]# fail2ban-server start
注:如果启动后修改配置文件不要重启服务可以用命令 “fail2ban-client reload” 来重新加载配置。
6、查看监控asterisk日志状态:
[root@pbx fail2ban]# fail2ban-client status
7、日志文件地址:
tail -f /var/log/fail2ban.log
可参考:
http://www.fail2ban.org/wiki/index.php/Fail2ban:Community_Portal#Add_support_for_MySQL_general_log_timestamps
https://my.oschina.net/monkeyzhu/blog/418592
http://netsecurity.51cto.com/art/201409/452112.htm
1、官网下载地址:https://github.com/fail2ban/fail2ban/releases
fail2ban-0.9.6.tar.gz 0.9.6的版本
2、解压后安装:
点击(此处)折叠或打开
- tar zxvf fail2ban-0.9.6.tar.gz
- cd fail2ban-0.9.6
- ./setup.py build
- ./setup.py install
[root@pbx fail2ban]# vim /etc/fail2ban/jail.conf
点击( 此处 )折叠或打开
[asterisk]
enabled = true ;开启(true)关闭(false)
findtime = 60 ;统计匹配日志文件的时间范围
bantime = 300 ;防火墙生效多久(持续时长)
port = 6871,5060 ;端口
filter = asterisk ;指定要对应的filter(相当于匹配注册失败ip的方法)对应配置文件啊”/etc/fail2ban/filter.d/asterisk.conf",这里不用修改
action = iptables-allports[name=asterisk, protocol=all] ;要执行的防火墙动作
logpath = /var/log/asterisk/messages ;要监控的服务的日志文件
maxretry = 10 ;匹配10次后会执行对应的动作
enabled = true ;开启(true)关闭(false)
findtime = 60 ;统计匹配日志文件的时间范围
bantime = 300 ;防火墙生效多久(持续时长)
port = 6871,5060 ;端口
filter = asterisk ;指定要对应的filter(相当于匹配注册失败ip的方法)对应配置文件啊”/etc/fail2ban/filter.d/asterisk.conf",这里不用修改
action = iptables-allports[name=asterisk, protocol=all] ;要执行的防火墙动作
logpath = /var/log/asterisk/messages ;要监控的服务的日志文件
maxretry = 10 ;匹配10次后会执行对应的动作
[root@pbx fail2ban]# vim /etc/fail2ban/action.d/iptables-common.conf
点击(此处)折叠或打开
- lockingopt = -w
- 改为
- lockingopt =
5、启动fail2ban 服务:
[root@pbx fail2ban]# fail2ban-server start
注:如果启动后修改配置文件不要重启服务可以用命令 “fail2ban-client reload” 来重新加载配置。
6、查看监控asterisk日志状态:
[root@pbx fail2ban]# fail2ban-client status
点击(此处)折叠或打开
- Status
- |- Number of jail: 1
- `- Jail list: asterisk
tail -f /var/log/fail2ban.log
http://www.fail2ban.org/wiki/index.php/Fail2ban:Community_Portal#Add_support_for_MySQL_general_log_timestamps
https://my.oschina.net/monkeyzhu/blog/418592
http://netsecurity.51cto.com/art/201409/452112.htm