UFW - Technological watch

Learn what UFW (Uncomplicated FireWall) in less than 5 minutes !
Wednesday, November 15, 2023

As the digital landscape continues to evolve, ensuring the security of your system is paramount. One tool that simplifies the complex world of firewall management is UFW, or Uncomplicated Firewall. In this blog post, we’ll delve into the problems UFW aims to resolve, the installation process, and key commands for effective firewall configuration.


UFW addresses the complexities associated with configuring firewalls, making it accessible even for users with limited networking expertise.

UFW gives simplicity in configuration. Traditional firewalls often involve intricate setups and complex rules. UFW simplifies this process, providing an easy-to-understand interface for users to define rules without delving into complex networking concepts.

UFW has graphical frontends, like GUFW.


Installing UFW is a straightforward process. Depending on your Linux distribution, use the appropriate package manager:

  • Ubuntu/Debian:
Terminal window
sudo apt-get update
sudo apt-get install ufw
  • CentOS/RHEL:
Terminal window
sudo yum install ufw

Enable IPv6 (optional)

Terminal window
sudo nano /etc/default/ufw
# add the conf:
# IPV6=yes

Configure UFW

Terminal window
# Default configuration :
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow ssh # or : sudo ufw allow 22

The first two lines are the default policy rules. This implies that individuals attempting to access your server would be unable to establish a connection, but any application within the server would still have the capability to connect to external entities.

The third line enables SSH connections to the server. Without this line, there is a risk of being locked out from external access.

Enable UFW

Finally, we can enable UFW with this command :

Terminal window
sudo ufw enable

Key commands

  1. Check Status:
Terminal window
sudo ufw status
  1. Allow Connections:
Terminal window
sudo ufw allow <port_number>
sudo ufw allow <protocol>
# Example
sudo ufw allow 80
sudo ufw allow http
# Or you can allow an IP range like this
sudo ufw allow 30000:30100/tcp
sudo ufw allow 30000:30100/udp
  1. Deny Connections: To deny connections on a specific port:
Terminal window
sudo ufw deny <port_number>
sudo ufw deny <protocol>
# Example
sudo ufw deny 80
sudo ufw deny http
  1. Allow/Disallow Specific IP: To allow or deny connections from a specific IP address:
Terminal window
sudo ufw allow from <IP_address>
sudo ufw deny from <IP_address>
sudo ufw allow from <IP_address> to any port 22
  1. Delete Rule:
Terminal window
sudo ufw status numbered
sudo ufw delete <rule_number>
# or
sudo ufw delete allow http
  1. Check the status:
Terminal window
sudo ufw status verbose
  1. Disabled Firewall:
Terminal window
sudo ufw disable
  1. Reset Firewall:
Terminal window
sudo ufw reset

These commands form the foundation for configuring UFW according to your specific security requirements.


In conclusion, UFW serves as a powerful yet user-friendly tool for managing firewalls on Linux systems. By simplifying the configuration process and offering an accessible interface, UFW enables users to enhance their system’s security without the need for extensive networking knowledge.

Recommended articles