The cart is empty

Linux provides robust options for firewall management, and one of the simplest tools available is UFW (Uncomplicated Firewall). This tool allows users to easily configure a firewall to protect their system without the need for advanced knowledge of iptables. In this article, we will show you how to properly set up a firewall using UFW in a Linux environment.

What is UFW?

UFW, or Uncomplicated Firewall, is a tool designed to simplify iptables management. It provides an intuitive interface for users who do not need or want to use the more complex settings directly via iptables. UFW is pre-installed on most Ubuntu distributions and can easily be installed on other Linux distributions as well.

Installing UFW

If you don't have UFW installed on your system, you can easily install it using the following command:

sudo apt install ufw

Basic UFW Management Commands

After installation, you can start configuring your firewall. Here are some basic commands to work with UFW:

  • sudo ufw status – Displays the current status of the firewall (enabled/disabled).
  • sudo ufw enable – Enables UFW and starts filtering traffic.
  • sudo ufw disable – Disables UFW.
  • sudo ufw reset – Resets all firewall settings.

Opening and Blocking Ports

UFW is ideal for allowing or blocking specific ports. For example, to allow SSH traffic on port 22, use:

sudo ufw allow 22

To block a specific port, use the command:

sudo ufw deny 80

Allowing IP Addresses

If you need to allow access to your server only from a specific IP address, such as 192.168.0.1, use the following command:

sudo ufw allow from 192.168.0.1

Advanced Options

UFW also allows more advanced configurations, such as allowing traffic on specific ports only from certain IP addresses. For example, to allow access to port 80 only from IP address 192.168.0.1, use:

sudo ufw allow from 192.168.0.1 to any port 80

Checking and Maintaining the Firewall

After configuring your firewall, it's important to regularly check its status and logs:

  • sudo ufw status verbose – Displays detailed information about the current firewall status.
  • sudo ufw logs – Displays firewall logs.

 

Setting up a firewall using UFW in Linux is a simple and effective solution for securing your system. With its intuitive interface and easy configurability, UFW is an ideal choice for users who want control over their system without complicated iptables commands. Make sure to regularly check the firewall status and logs to ensure it is functioning properly and securely.