[root@xiaolyu76 fail2ban-0.8.14]# vim README.md
#说明:下面的readme仅仅是我择要摘取,原文太长了。
This README is a quick introduction to Fail2ban. More documentation, FAQ, HOWTOs
are available in fail2ban(1) manpage and on the website http://
Installation:
-------------
**It is possible that Fail2ban is already packaged for your distribution. In
this case, you should use it instead.**
Required:
- [Python >= 2.4](http://)
Optional:
- [pyinotify >= 0.8.3](https://github.com/seb-m/pyinotify)
- Linux >= 2.6.13
- [gamin >= 0.0.21](http://~veillard/gamin)
To install, just do:
tar xvfj fail2ban-0.8.12.tar.bz2
cd fail2ban-0.8.12
python setup.py install
This will install Fail2Ban into /usr/share/fail2ban. The executable scripts are
placed into /usr/bin, and configuration under /etc/fail2ban.
需要安装python开发环境,并且版本要大于2.4
查看当前系统中python的版本:
[root@xiaolyu76 ~]# python -V
Python 2.6.6
[root@xiaolyu76 ~]# cd fail2ban-0.8.14
[root@xiaolyu76 fail2ban-0.8.14]# ls setup.py
setup.py
[root@xiaolyu76 fail2ban-0.8.14]# python setup.py install
生成服务启动脚本:
#下面是生成服务启动脚本的程序:
[root@xiaolyu76 fail2ban-0.8.14]# pwd
/root/fail2ban-0.8.14
[root@xiaolyu76 fail2ban-0.8.14]# grep chkconfig ./* -R --color #查看服务启动脚本是哪个文件,同时着色显示。
./files/RedHat-initd:# chkconfig: - 92 08
[root@xiaolyu76 fail2ban-0.8.14]# cp files/redhat-initd /etc/init.d/fail2ban #将服务启动脚本复制到存放开机启动的服务的目录下
[root@xiaolyu76 fail2ban-0.8.14]# chkconfig --add fail2ban #设置服务的开机启动
[root@xiaolyu76 fail2ban-0.8.14]# service fail2ban start #service fail2ban start|stop|status|restart测试服务是否正常
Starting fail2ban: [ OK ]
[root@xiaolyu76 fail2ban-0.8.14]# service fail2ban status
fail2ban-server (pid 5874) is running...
Status
|- Number of jail: 0
`- Jail list:
[root@xiaolyu76 fail2ban-0.8.14]# service fail2ban restart
Stopping fail2ban: [ OK ]
Starting fail2ban: [ OK ]
[root@xiaolyu76 fail2ban-0.8.14]# service fail2ban stop
Stopping fail2ban: [ OK ]
[root@xiaolyu76 fail2ban-0.8.14]#
为什么要生成服务启动脚本呢?生成服务启动脚本,我可以设置开机自启动,可以使用服务的相关命令service 服务名 start|stop|restart|status等等。非常方便。
拓展:
grep的用法
grep ssh /etc/passwd
2)echo -e “this is a world \n nest line” |grep world
3)打印除包含 math_pattern 行之外的所有的行
grep -v match_pattern file
4)统计文件或文本中包含匹配字符串的行数:
grep -c “test” filename
5)忽略大小写
echo “hello world” |grep -I “HELLO”
2、用tree /etc/fail2ban来查看fail2ban的文件目录树。
[root@xiaolyu76 ~]# tree /etc/fail2ban
通过文件树,可以看到在安装fail2ban的过程中生成了很多文件,这里给出相关主要文件说明:
/etc/fail2ban/action.d #动作文件夹,内含默认文件。iptables以及mail等动作配置
/etc/fail2ban/fail2ban.conf #定义了fai2ban日志级别、日志位置及sock文件位置
/etc/fail2ban/filter.d #条件文件夹,内含默认文件。过滤日志关键内容设置