How to install and setup Fail2ban on CentOS?

Fail2ban is a software used to ban IP’s which shows strange behavior. It can be configured to reject IP’s for a certain amount of time.

To install Fail2ban we need to download the application from the source. Login as the root user and go to /opt

$ cd /opt

$ wget http://downloads.sourceforge.net/project/fail2ban/fail2ban-stable/fail2ban-0.8.4/fail2ban-0.8.4.tar.bz2?use_mirror=transact

Next unzip the downloaded file

$ tar -xf fail2ban-0.8.4.tar.bz2

$ cd fail2ban-0.8.4

To install

$ python setup.py install

$ cp files/redhat-initd /etc/init.d/fail2ban

To add fail2ban to the service

$ chkconfig –add fail2ban

$ chkconfig fail2ban on

Next is to configure the jail.conf where the settings are given by default for the local host

$ vi /etc/fail2ban/jail.conf

Go to the line where “ignoreip” keyword is mentioned and add the list of IP’s or IP subnet from which you want to gain access to the service

Finally, start fail2ban application

$ service fail2ban start

Share it onShare on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn

Written by kurinchilamp


Website: http://

Leave a Reply

Your email address will not be published. Required fields are marked *

Read previous post:
Java Tomcat – SEVERE: Catalina.stop: java.net.ConnectException: Connection refused

This error pops up when you try to stop the Tomcat server when the server has not started. If you...

Close