Fail2Ban is a popular open-source tool used to protect Linux servers from brute-force attacks, password guessing, and other malicious activity. It works by monitoring log files for specific patterns of activity and then blocking IP addresses associated with that activity for a specified period of time.

Here are the steps to configure Fail2Ban on your Linux server:

1. Install Fail2Ban: Use the package manager of your Linux distribution to install Fail2Ban. For example, on Ubuntu, you can use the following command:

```
sudo apt-get install fail2ban
```

2. Configure the Jail: Fail2Ban uses a "jail" to define the settings for monitoring and blocking specific types of activity. The default jail configuration is located in `/etc/fail2ban/jail.conf`. Copy this file to `/etc/fail2ban/jail.local` to create a custom configuration:

```
sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
```

3. Edit the Jail Configuration: Open `/etc/fail2ban/jail.local` in a text editor and configure the settings for the services you want to protect. For example, to protect SSH, add the following to the `[sshd]` section:

```
enabled = true
port = ssh
filter = sshd
logpath = /var/log/auth.log
maxretry = 5
banaction = iptables-multiport
bantime = 1h
```

This configuration will monitor the `/var/log/auth.log` file for SSH login attempts and block IP addresses that exceed 5 failed attempts within an hour.

4. Restart Fail2Ban: After editing the jail configuration, restart Fail2Ban to apply the changes:

```
sudo systemctl restart fail2ban
```

5. Verify Fail2Ban is Working: Check the Fail2Ban log file to verify that it is blocking IP addresses:

```
sudo cat /var/log/fail2ban.log
```

Fail2Ban is an effective tool for protecting your Linux server from malicious activity. By configuring Fail2Ban jails, you can monitor and block specific types of activity and ensure the security of your server.

Дали Ви помогна овој одговор? 53 Корисниците го најдоа ова како корисно (41 Гласови)