Knowledge Base

Using fail2ban to harden a server

Installing and configuring fail2ban to help secure a server is explained in this article. You may set up fail2ban on your server to automatically prohibit IP addresses that exhibit questionable behavior.

Regarding fail2ban

The fail2ban program keeps an eye on server log files to look for unusual activity, including intrusion attempts. Failure2ban automatically bans a host's IP address for a predetermined amount of time after a predetermined number of host failures.

You may protect your server from unwanted access attempts by using fail2ban. It works especially well to lower the danger of botnets and automated assaults.

Setting up fail2ban

The fail2ban package may be installed on your Linux distribution by:

  • Enter this command for Ubuntu and Debian:
apt-get install fail2ban
  • Enter the following command to access Fedora and AlmaLinux:
yum install fail2ban

Setting up fail2ban

You are prepared to setup fail2ban after you have installed it. To do this, take these actions:

  1. Use SSH to access your server.

  2. Enter the following command at the command prompt:

  3. In the text editor of your choice, open the jail.local file.
    Find the [DEFAULT] section, which has the global settings shown below:

  4. You can designate IP addresses or hostnames that fail2ban will disregard by using the ignoreip option. To ensure fail2ban doesn't stop you from accessing your own server, you may, for instance, include your home or office IP address. If you want to give more than one address, use a space between them. For instance:
Please rate this article to help us improve our Knowledge Base.

0 0