How to install ufw firewall on ubuntu serverHow to install ufw firewall on ubuntu server

To install a firewall on a Linux server, you can use the ufw (Uncomplicated Firewall) command line utility. Here are the steps to follow:

  1. Before you start, make sure that you are logged in as a user with sudo privileges.
  2. To check if ufw is installed on your system, run the following command:
sudo ufw status

If ufw is not installed, you can install it with the following command:

sudo apt-get update
sudo apt-get install ufw
  1. Once ufw is installed, you can enable it with the following command:
sudo ufw enable
  1. By default, ufw will allow all outgoing connections and block all incoming connections. If you want to allow incoming connections, you can use the ufw allow command to specify the ports or services that you want to allow. For example, to allow incoming SSH connections, you can use the following command:
sudo ufw allow ssh
  1. You can also use the ufw deny command to block incoming connections on specific ports or services. For example, to block incoming HTTP connections, you can use the following command:
sudo ufw deny http
  1. After making any changes to the firewall rules, you can use the ufw status command to check the status of the firewall and see a list of the allowed and denied connections.