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

Next unzip the downloaded file

$ tar -xf fail2ban-0.8.4.tar.bz2

$ cd fail2ban-0.8.4

To install

$ python 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


Written by kurinchilamp

Website: http://

Leave a Reply

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