Enhancing Skills

Enabling Firewall, Opening & Closing Ports, and Managing Services in Ubuntu

A step-by-step guide to secure your server and manage network connections

Table of Contents:

  1. Installing Uncomplicated Firewall (UFW)
  2. Enabling the Firewall
  3. Opening a Port
  4. Closing a Port
  5. Checking the Firewall Status

Section 1: Installing Uncomplicated Firewall (UFW)

1.1. Ubuntu comes with a built-in firewall called Uncomplicated Firewall (UFW). To install it, run the following command in your terminal:

sudo apt update && sudo apt install ufw -y

1.2. After installation, you can proceed to the next section.

Section 2: Enabling the Firewall

2.1. To enable the firewall, run the following command in your terminal:

sudo ufw enable

2.2. When prompted, enter your password and press ENTER to confirm. The firewall will be enabled, and UFW rules will be applied.

Section 3: Opening a Port

3.1. To open a specific port, run the following command in your terminal:

sudo ufw allow [port_number]

Replace [port_number] with the desired port number, such as 22 for SSH or 8059 for WebUI. This will add a rule to UFW to allow incoming traffic on the specified port.

Section 4: Closing a Port

4.1. To close a specific port, run the following command in your terminal:

sudo ufw delete [port_number]

Replace [port_number] with the desired port number to remove the rule allowing incoming traffic on that port.

Section 5: Checking the Firewall Status

5.1. To check the current status of your firewall, run the following command in your terminal:

sudo ufw status

This will display information about your firewall’s active rules and whether it is enabled or disabled.

Conclusion:

With these steps, you can now enable and manage your firewall, open and close ports, and start, and stop UFW on your Ubuntu server. This will help you enhance the security and performance of your server.


Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.