• Contact
  • Contact Us
  • Disclamer
  • Home 1
  • Home 2
  • Home 3
  • Privacy Policy
Saturday, May 17, 2025
How VPS - How to use/setup VPS
  • Login
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
How VPS - How to use/setup VPS
No Result
View All Result
Home VPS/Servers management guides

How to Setup Fail2ban on your Ubuntu 18.04 VPS Server or Dedicated Server

How VPS by How VPS
November 2, 2018
in VPS/Servers management guides
0
0
SHARES
51
VIEWS
Share on FacebookShare on Twitter

Contents

  1. Prerequisite
  2. Step 1: Update the Package Information and Install Fail2ban
  3. Step 2: Understanding Fail2Ban configuration file
  4. Step 3: Creating a custom configuration file
  5. Conclusion
  6. Check out these top 3 VPS services:
    1. Was this article helpful?

Fail2ban is an intelligent Utility that scans log files to mitigate malicious attacks on your server. The tool blocks IP addresses that lead to too many password failures.

If you are running Ubuntu 18.04 VPS, then Fail2ban should give your server an edge in fighting hackers automatically. The software can update firewall rules on its own to block IP addresses trying to exploit your server.

Fail2ban has excellent features that limit unauthorized access to your server especially through services such as SSH (Secure Shell), Apache web server, Courier Mail server, FTP and more.

In this guide, we will show you how you can setup and customize fail2ban to protect your Ubuntu 18.04 server.

Prerequisite

  • A VPS web hosting plan (need help? consult with our VPS hosting reviews)
  • A non-root username that can perform sudo tasks
  • Shell access to your Linux server. You can use PuTTY if you are running windows or default command line terminal on Linux and Mac.

Step 1: Update the Package Information and Install Fail2ban

First, we need to make sure we have the latest package list from the Ubuntu repository. To get the newest versions of the packages and their dependencies, run the command below:

$ sudo apt-get update

We can now install Fail2ban:

$ sudo apt-get install fail2ban

Press Y and hit Enter when prompted to confirm the installation.

Step 2: Understanding Fail2Ban configuration file

Fail2Ban comes with default filtering rules but you might create your own configuration file to customize different security settings depending on your needs.

The default configuration file (‘/etc/fail2ban/jail.conf’) should never be edited because it can be improved or overwritten in a distribution update or during upgrades.

The default behavior of Fail2ban is to read ‘.conf’ files first followed by ‘.local’ files. That means you should create your own ‘.local’ file if you want to provide your own customizations and override the default settings.

If you want multiple configuration files to handle the security of each service separately, put the ‘.local’ files under ‘/etc/fail2ban/jail.d’ directory.

Step 3: Creating a custom configuration file

Although we can create a default configuration file from scratch, we can just copy the default configuration file and only edit the settings that we want to override.

To do this, run the command below

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

To edit the new configuration file, open it using a nano editor:

$ sudo nano /etc/fail2ban/jail.local

We may wish to edit the settings under the [DEFAULT] entry:

[DEFAULT]

...
$ bantime =10m
$ findtime =10m
$ maxretry=5
...

The settings above all applied for every service that does not have the entries overridden in the services own section.

  • ‘bantime’ represents the time that a host is banned before it can be allowed to try the service again.
  • ‘findtime’ is the maximum amount of time fail2ban should wait before banning a host if it has generated the maximum retries allowed for a particular service.
  • ‘maxretry’ indicates the number of failures that a host should generate before it is banned by the server

The default settings above indicate that a host will be blocked for 10 minutes if it generates more than 5 failed attempts within 10 minutes.

You can modify these settings to suit your needs

Towards the bottom of the files, the configuration files contain information for each service running on the server.

You may tweak the settings of each service depending on your needs.

Once you are through editing the file. Press CTRL+X, Y, and Enter to save the file.

Conclusion

In this guide, we have shown you how to install Fail2Ban on Ubuntu 18.04 VPS server. We have also discussed how Fail2Ban treats configuration file and went ahead to create a file to handle our custom settings.  You can use all these steps to stop malicious users from hacking your Ubuntu 18.04 server.

 

Check out these top 3 VPS services:

0

Was this article helpful?

Submit
Previous Post

How To Configure Nginx Server Blocks on an Ubuntu 18.04 VPS or Dedicated Server

Next Post

How To Install Anaconda Python on Ubuntu 18.04 LTS

Next Post

How To Install Anaconda Python on Ubuntu 18.04 LTS

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

No Result
View All Result

Recent Post

Install Imagemagick on CentOS
CentOS

Install Imagemagick on CentOS

by How VPS
June 28, 2023
0

This is how I installed Imagemagick on a vanilla CentOS server Start off by installing the prerequisites yum install php-pear...

Read more
how to Check phpinfo

How to Check phpinfo of Hosting or VPS?

June 28, 2023
Failed to download metadata for repo 'appstream' on Centos 8

How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

February 25, 2022
How to Fix MySQL Error "Plugin 'InnoDB' registration as a STORAGE ENGINE failed"?

How to Fix MySQL Error “Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed”?

November 17, 2020
How to optimize Mysql or MariaDB

How to optimize Mysql or MariaDB

November 3, 2020

Recent News

  • Install Imagemagick on CentOS
  • How to Check phpinfo of Hosting or VPS?
  • How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

Category

  • Arch
  • Authentication
  • Backups
  • BSD
  • Centmin Mod
  • CentOS
  • Control Panels
  • CoreOS
  • CWP
  • Debian
  • Directadmin
  • Encryption
  • Fedora
  • Firewalls
  • Hocvps Script
  • Hosting providers
  • Kloxo-MR
  • Linux
  • Mitigations
  • Operating System
  • Plesk
  • Reviews
  • Securing VPS/Servers
  • Security Patches
  • SSL Certificates
  • Uncategorized
  • Upgrading
  • VPS/Servers management guides
  • Vulnerability Detection
  • Web servers software
  • Webhosting Control Panel
  • About
  • Advertise
  • Careers
  • Contact

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.

No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In
Thabet