fbpx

Fail2ban software is an intrusion prevention framework on your CentOS 7 (and 6) vps that scans log files and bans IPs that show the malicious signs so you can protect your server from brute-force attacks. Some previously posted some including to change default SSH port and to disable root login directly, will help you to secure your server, and Fail2ban is one more step in that direction. Brute-force attack may occur continuously, Fail2Ban is then used to update firewall rules to reject the IP addresses for a specified amount of time. Fail2Ban is able to reduce the rate of incorrect authentications attempts because Fail2Ban comes with filters for various services (apache, courier, ssh, etc)..

Here is a video for you to follow, or go to the steps down below.

HOW TO INSTALL

Step 1 – Now install it using yum:

1
yum install fail2ban -y

1

HOW TO CONFIGURE FAIL2BAN

Step 2 – So now fail2ban is installed on your VPS, what next to do is setting up some basic Fail2ban configuration. Here I’ll show you a very basic setup. Now firstly copy default configuration file:

1
cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local

2

This task is necessary so you can edit configuration locally (your own setting) without messing up with default one. There are lot of possible services that may need protection are in the jail.local file already.

Step 3 – Now edit jail.local file you copied. Use your favorite text editor like Nano or vi.

1
nano /etc/fail2ban/jail.local

3

Step 4 – Scroll down the page for all available configuration. There are few lines act as basic setup you can edit as necessary to suit your need including: ignoreip, bantime, findtime, and maxretry. You can read what each line means in the explanation available there.

In the β€œignoreip” line you can define several IPs to whitelist so fail2ban won’t lock out that IP. Here you can add your personal / home IP address in case if your forgot your own password to login to your server.

4

Step 5 – Now restart Fail2ban so the new configuration can take effect.

CentOS 7:

1
systemctl restart fail2ban.service

CentOS 6:

1
service fail2ban restart

That’s it. Enjoy..

 

Categories: Tutorials

0 Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.