UFW

The acronym "UFW" stands for "Uncomplicated Firewall" and refers to an application that aims to set rules in "iptables", the native firewall tables in Linux.

UFW


UFW (Uncomplicated Firewall) is an easy-to-use firewall tool that is commonly used on Linux-based operating systems.


UFW is based on iptables, the native Linux firewall, and provides a simpler and friendlier interface to interact with it. Allows users to define network packet filter rules to control what traffic is allowed and what traffic is blocked on the system. You can use UFW to protect your machine from potential threats and limit access to specific services.


UFW (Uncomplicated Firewall) is a practical choice for managing firewall settings on Linux systems for several reasons:


Simplicity and ease of use: As the name suggests, UFW aims to simplify firewall configuration and management. It provides a user-friendly command-line interface, making it accessible even to users with limited networking and security knowledge.


Built on iptables: UFW is built on top of iptables, the native firewall solution in Linux. While iptables offers powerful capabilities, it can be complex and challenging for newcomers. UFW acts as a user-friendly frontend, abstracting away the intricacies of iptables.


Enhanced security: By employing UFW, users can strengthen the security of their Linux systems. UFW allows for fine-grained control over incoming and outgoing traffic, enabling users to define rules that only permit essential connections while blocking unwanted access attempts.


Protection against network scans and attacks: UFW can thwart port scanning and various network-based attacks. Configuring UFW rules to control incoming traffic can help prevent potential attackers from probing the system for vulnerabilities.


Granular access control to specific services: UFW enables users to restrict access to specific services such as SSH, HTTP, or FTP. This level of control helps prevent unauthorized connections and enhances overall system security.


Easy enablement and disablement of the firewall: UFW allows users to quickly enable or disable the firewall as needed. This flexibility is advantageous when making changes to the configuration or temporarily requiring unrestricted traffic for debugging or maintenance purposes.


Audit and logging capabilities: UFW logs firewall actions, providing an audit trail for analyzing blocked and allowed connections. This feature assists in monitoring and investigating potential security incidents.


Integration with scripts and automation: UFW commands can be incorporated into scripts, facilitating automated firewall rule deployment and configuration management across multiple systems.


Overall, UFW strikes a balance between usability and functionality, making it an excellent choice for users seeking a straightforward firewall solution on Linux.


Installation and basic commands


Check if UFW is installed:


  sudo apt update
  sudo apt install ufw


Enable UFW: 


  sudo ufw enable


Configure rules

You can set up UFW rules to allow or deny incoming and outgoing connections. For example, to allow SSH traffic, use:


  sudo ufw allow ssh


Allow traffic for a specific port:


  sudo ufw allow <port>


Deny traffic for a specific port:


  sudo ufw deny <port>


Delete a specific rule:


  sudo ufw delete <number>


Deny all incoming traffic:


  sudo ufw default deny incoming


Allow all outgoing traffic:


  sudo ufw default deny incoming


Allow/deny traffic based on specific IP addresses:


  sudo ufw allow from <ip_address> to any port <port_number>
  sudo ufw deny from <ip_address> to any port <port_number>


Allow/Deny traffic based on a range of IP addresses:

sudo ufw allow from <start_ip>-<end_ip> to any port <port_number>

  sudo ufw deny from <start_ip>-<end_ip> to any port <port_number>


Check UFW status:


  sudo ufw status