Advance

Tutorial Limit SSH with UFW Firewall on CentOS

Tutorial Limit SSH with UFW Firewall on CentOS
3
(2)

A firewall is a tool for monitoring and filtering incoming and outgoing network traffic. It defines a set of security rules that allow or block certain traffic. UFW is a user-friendly view for managing iptables firewall rules. Its main purpose, as its name implies, is to make firewall management easier. In this article, we are going to teach you How to Limit SSH with UFW Firewall on CentOS. You can visit the packages available in Eldernode if you wish to purchase a CentOS VPS server.

How to Limit SSH with UFW Firewall on CentOS [7, 8]

Recommended Article: Tutorial Configure SSH Key-Based Authentication on a Linux Server

How to Setup UFW Firewall on CentOS

To fully learn this tutorial, we need to teach you the Setup UFW Firewall On CentOS first in this section. To do this, just follow the steps below.

In the first step, it is necessary to make sure you have activated REPO EPEL. So need to install UFW with the following command:

sudo yum -y install ufw

Now you can view the UFW installation status using the following command:

sudo ufw status

Limit SSH with UFW Firewall on CentOS [7, 8]

In this section, we are going to show you How to Limit SSH with UFW Firewall on CentOS. To do this, pay attention to the continuation of this tutorial. Now the point to note is that a basic firewall denies all input traffic and allowing output traffic, a good place to get started. You can easily adjust the default rules using the following commands:

sudo ufw default deny incoming
sudo ufw default allow outgoing

You can open any services you want on the Internet if you want. For example, you can open the firewall like the following commands:

sudo ufw allow ssh

or

sudo ufw allow https

As you see in the following command, for non-standard or unusual ports you can specify the port number instead of the service:

sudo ufw allow 2222

You can further narrow this down to protocol too by adding it to the end using the following command:

sudo ufw allow 2222/tcp

You can add a range of ports for FTP using the following command:

sudo ufw allow 3000:4000/tcp

You may have a fixed IP and want to allow all network traffic. In this case, you should use the following command:

sudo ufw allow from 123.123.123.123

You can also block traffic via IP by running the following command:

sudo ufw deny from 123.123.123.123

You can adjust the firewall with the help of the following command:

sudo systemctl enable ufw

Finally, you can issue the following command to disable the firewall:

sudo ufw disable
Recommended Article: Tutorial Install PlayOnLinux on Ubuntu 20.04 LTS

Conclusion

By default, the UFW firewall blocks all incoming and outgoing connections and allows all outgoing connections. This means that anyone who wants to access your server will not be able to connect unless you specifically open the port. In this article, we tried to teach you How to Limit SSH with UFW Firewall on CentOS. You can refer to the article Tutorial Limit SSH with UFW on Ubuntu 20.04 if you wish.

How useful was this post?

Click on a star to rate it!

Average rating 3 / 5. Vote count: 2

No votes so far! Be the first to rate this post.

We Are Waiting for your valuable comments and you can be sure that it will be answered in the shortest possible time.

Leave a Reply

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

We are by your side every step of the way

Think about developing your online business; We will protect it compassionately

We are by your side every step of the way

+8595670151

7 days a week, 24 hours a day