A firewall is the most appropriate form of computer security to consider for allowing inbound and outbound packet transfers. It is very important due to the multiple threats and new generations of hackers attempting to breach ports and access.
This tool may or may not be enabled by default depending on the version of the Debian and Ubuntu distribution. It was developed specifically to simplify the administration of iptables firewalls. Below, you will discover the simple methods for creating basic rules.
Installing UFW
Installing UFW is easy.
apt update
apt install ufw
Basic Usage
Enable firewall: ufw enable
Disable firewall: ufw disable
Display status: ufw status
Display numbered rule list: ufw status numbered
Block all incoming traffic: ufw default deny incoming
Allow all incoming traffic: ufw default allow incoming
Block port 22: ufw deny 22
Allow port 22: ufw allow 22
Block port 22 only for a specific user: ufw deny from 123.52.12.55 to any port 22
UFW Considerations
Below are some important considerations for this work.
1. You need root (sudo) permissions to install and manage the package.
2. UFW is disabled by default.
3. Before enabling it, you must allow SSH access so you don't get locked out of your own server: (ufw allow 22) or (ufw allow SSH)
4. The ports required for a web application are port 80 for the http protocol and 443 for the https protocol. You can also enable both using ufw allow "WWW Full"
https://www.youtube.com/watch?v=el0ATPPMwnE&feature=youtu.be&ab_channel=MoxNetworks
More information on Wikipedia