Projekt

Allgemein

Profil

Aktionen

Setup fail2ban » Historie » Revision 2

« Zurück | Revision 2/9 (Vergleich) | Weiter »
Jeremias Keihsler, 22.10.2021 12:22


Setup fail2ban

Requirements

To install fail2ban you will need the following:
  • a installed and supported operating system (e.g. CentOS 8.x)
  • root-access
  • a fast internet connection
  • EPEL

Preliminary Note

This procedure is based on a documentation taken from:

Most Linux servers offer an SSH login via Port 22 for remote administration purposes. This port is a well-known port, therefore, it is often attacked by brute force attacks. Fail2ban is a software that scans log files for brute force login attempts in real-time and bans the attackers with firewalld or iptables. Fail2ban recognizes unwanted access or security breach efforts to the server within the administrator set time frame and blocks the IP addresses which show signs of brute force attacks or dictionary attacks. This program works in the background and continuously scans the log files for unusual login patterns and security breach attempts.

Install

yum install fail2ban

if you are into noise ...

yum install whois

Start/Enable Service

systemctl enable fail2ban
systemctl start fail2ban

config

The /etc/fail2ban/jail.local file overrides defaults set in /etc/fail2ban/jail.conf file. Therefore, create or edit the jail.local

[DEFAULT]
# Ban IP/hosts for 24 hour ( 24h*3600s = 86400s):
bantime = 86400

# An ip address/host is banned if it has generated "maxretry" during the last "findtime" seconds.
findtime = 600
maxretry = 3

# "ignoreip" can be a list of IP addresses, CIDR masks or DNS hosts. Fail2ban
# will not ban a host which matches an address in this list. Several addresses
# can be defined using space (and/or comma) separator. For example, add your 
# static IP address that you always use for login such as 103.1.2.3
#ignoreip = 127.0.0.1/8 ::1 103.1.2.3

# Call iptables to ban IP address
banaction = iptables-multiport

# Enable sshd protection
[sshd]
enabled = true

Status

fail2ban-client status
fail2ban-client status <jail>
fail2ban-client status sshd

unban IP

fail2ban-client set <jail> unbanip <ip>
fail2ban-client set sshd unbanip 123.123.123.123

Von Jeremias Keihsler vor etwa 3 Jahren aktualisiert · 2 Revisionen