How to Install & Configure Fail2ban on Debian 10 or 11

Every server connected to the Internet is vulnerable to brute-force and virus attacks. Hackers attempt to gain access to apps accessible on ...

Every server connected to the Internet is vulnerable to brute-force and virus attacks.

Hackers attempt to gain access to apps accessible on public networks by brute-forcing them.

Fail2ban is a utility that improves the security of Linux-based machines to prevent them from automated attacks.
It scans the logs for malicious activity and allows the user to block distant IP addresses temporarily or permanently.

On a Debian 11-based system, this how-to tutorial will show you how to install, configure, and set up Fail2ban. 

How to Install & Configure Fail2ban on Debian 10 or 11

Fail2ban is available in Debian 11's default repository, making it simple to install using Debian's default package manager:
$ sudo apt install fail2ban -y 

After successful installation, the Fail2ban service should start automatically. You may check this by executing the following command:

$sudo systemctl status fail2ba

If the service is not running on your system, you can start and activate it with the following commands:

$ sudo systemctl start fail2ban 
$ ssudo systemctl enable fail2ban 

How to configure Fail2ban on Debian 10 or 11

Fail2ban includes two configuration files, both of which can be found in the /etc/fail2ban directory.
These config files have a basic configuration that should not be changed because they may be rewritten if a package update is installed.

To avoid any future headaches, we can utilise a separate.local file as a configuration file.

So, by copying the jail.conf file, we'll create a local config file:
$ sudo cp /etc/fail2ban/jail.{conf,local} 

Now, open the newly created file in a text editor:

$ sudo nano /etc/fail2ban/jail.local 

You can change the settings here to suit your needs.

You can use the ignoreip directive to exclude IP addresses from the ban list.
As an example, I've listed two different IP addresses.
Any IP address you want to whitelist can be entered here:

ignoreip = 127.0.0.15/8  192.168.1.2/24

The bantime directive can be used to specify the length of time that an IP address will be blocked. A suffix like m,d can be used to designate the time unit, which is by default seconds.

bantime = 120m

The findtime directive specifies the duration of time for the number of failures before a ban is placed. If Fail2ban is going to ban an IP after 4 failed attempts, the findtime directive defines the time interval in which the failures must occur.

findtime = 2m

The maxretry is used to define the number of failed attempts before an IP gets blacklisted.

maxretry = 5

After making all the necessary changes, you can simply just save and save the config file.

Now restart the service to let the changes take effect:
$ sudo systemctl restart fail2ban.service

Conclusion

Fail2ban allows us to set up our system so that it is more safe against brute-force attacks and other harmful activity.
It safeguards our system by examining logs and blacklisting questionable IP addresses.
These safeguards are critical, especially for systems that are connected to the internet.
We learned how to install, configure, and set up Fail2ban on Debian 11 in this tutorial.

COMMENTS

Name

2023,2,Ai,2,AlmaLinux 9,3,Amazon Linux,5,Apache Web Server,1,AppImage,1,Arduino IDE,1,Artificial Intelligence,2,BalenaEtcher,1,Bitcoin,1,Blockchain Data,1,Bookworm,2,Bootable USB,1,C++,1,centos,1,CentOS 8,1,CentOS Stream,1,CMake,1,CockroachDB,2,cuDNN,1,Database Security,1,Debian,2,Debian 10,2,Debian 11,2,Debian 12,9,DNS,1,Docker,1,E-commerce,1,Fail2ban,1,Fedora Linux,1,Firefox 118,1,FreeIPA Server,1,Function,1,Game Projects,1,Git,3,Google PageSpeed,1,How to,5,How to Install,9,HTTPS,1,Introduction,1,Iptables,1,ISO Image,1,KVM,1,Laravel,1,Let's Encrypt SSL,1,Linux,4,Linux 6.4,1,Linux Kernel 6.5,1,Linux Mint,1,Linux Server,1,Linux-Based Systems,1,Mageia 9,1,Magento,1,MariaDB,1,Media Server,1,ModSecurity,1,New Features,1,Nextcloud,2,NGINX,2,Nvidia CUDA,1,odoo,1,Oracles,1,Performance,1,PHP Zip Module,1,pip,1,Plex,1,Port Forwarding,1,postgresql,2,Privacy,1,Programming,1,Pylint,1,python,5,Python 3.10,2,Quantum,1,Quantum Computers,1,Remote Branch,1,Renew,1,RHEL,1,Rocky Linux 9,2,Rufus,1,Shadow Password,1,SQLite,1,SSH,1,SSH key,1,SSH Keys,1,Step-by-Step,4,SuiteCRM,1,SUSE Linux,1,Syslog,1,System,1,Testing,1,Top 10,1,Translation,1,Ubuntu,1,Ubuntu 18.04,1,Ubuntu 20.04,5,Ubuntu 22.10,1,Ubuntu 23.04,1,Ubuntu Server,1,Ubuntu Upgrade,1,unsupported,1,Up-to-Date,1,Upgrade,1,Visual Studio Code,1,Vivaldi 6.2,1,Web 3.0,1,Web Hosting Security,1,Web Security,1,Webmin,1,What's New,1,Windows 11,1,
ltr
item
Linux code EDU: How to Install & Configure Fail2ban on Debian 10 or 11
How to Install & Configure Fail2ban on Debian 10 or 11
https://blogger.googleusercontent.com/img/a/AVvXsEhqdrjaxdUgqz9tLYxt4x8tfPW2FyU2He-QJ_bUyNSIM81B2Oji2e8dXcLwexTg4eb3KyumFXmiX5qa-1JSYBDFz3IRx13shbydUkMF_OcjU4YVCaO5IBzz8u5o_zJJqyfpbc55B_ItRUciCeeDkUCjWVPP563QHGH1cfPpNThMnsccG0qhfyKLJ-1XrQ=w640-h366
https://blogger.googleusercontent.com/img/a/AVvXsEhqdrjaxdUgqz9tLYxt4x8tfPW2FyU2He-QJ_bUyNSIM81B2Oji2e8dXcLwexTg4eb3KyumFXmiX5qa-1JSYBDFz3IRx13shbydUkMF_OcjU4YVCaO5IBzz8u5o_zJJqyfpbc55B_ItRUciCeeDkUCjWVPP563QHGH1cfPpNThMnsccG0qhfyKLJ-1XrQ=s72-w640-c-h366
Linux code EDU
https://linuxcodeedu.blogspot.com/2021/11/how-to-install-configure-fail2ban-on.html
https://linuxcodeedu.blogspot.com/
https://linuxcodeedu.blogspot.com/
https://linuxcodeedu.blogspot.com/2021/11/how-to-install-configure-fail2ban-on.html
true
6096992636254302192
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy Table of Content