Skip to main content

UFW Firewall Guide for Linux

· Updated: Jul 27, 2026 · Linux, Firewall, Security

Table of contents

Introduction to Uncomplicated Firewall (UFW)

Network security matters. Protecting your Linux system from unauthorized access is a critical step in maintaining its integrity. Uncomplicated Firewall (UFW) is a user-friendly interface for managing iptables, the default firewall management tool for Linux. UFW simplifies the process of configuring and managing firewall rules, making it accessible to users of all skill levels. This guide covers how UFW works and how to use it to secure your system.

What is UFW?

Uncomplicated Firewall (UFW) is an essential front-end for iptables, offering a straightforward and intuitive means to handle firewall rules. It caters to both newcomers and seasoned professionals, abstracting the complexities of iptables while retaining its powerful functionalities. With UFW, you can define rules to regulate inbound and outbound network traffic, significantly enhancing the security of your system.

Installation and Initial Steps

While UFW is often pre-installed on many Linux distributions, you can install it using your package manager if necessary. For instance:

Ubuntu/Debian based:

To install UFW on Ubuntu/Debian based systems, use the following command:

sudo apt-get install ufw

Arch-Based:

To install UFW on Arch-Based systems, use the following command:

sudo pacman -S ufw

Fedora:

To install UFW on Fedora, use the following command:

sudo dnf install ufw

These commands will ensure that UFW is installed and ready for configuration on your system.

Getting Started

Once installed, you can quickly enable UFW and begin using it. Here are the fundamental commands to kick-start your journey:

To enable UFW:

sudo ufw enable

To disable UFW:

sudo ufw disable

To check UFW status:

sudo ufw status

Essential Firewall Management

Allowing and Denying Connections

UFW adheres to a default deny-all policy, meaning it blocks all incoming connections until explicitly allowed. You can use the following commands to permit specific connections:

To allow incoming HTTP traffic:

sudo ufw allow 80/tcp

To allow incoming SSH traffic:

sudo ufw allow ssh

Deleting, Resetting, Denying, and Allowing Rules

To effectively manage firewall rules, UFW provides key commands:

To delete a rule by its number:

sudo ufw delete <rule_number>

To reset UFW to its default settings:

sudo ufw reset

To deny incoming connections to a specific port:

sudo ufw deny <port>

To allow incoming connections to a specific port:

sudo ufw allow <port>

To delete a specific “allow” rule:

sudo ufw delete allow http

Advanced Configuration and Customization

Application Profiles

UFW includes application profiles to simplify rule configuration for common services. To enable a profile, use:

sudo ufw allow <application_name>

Connection Rate Limiting

UFW empowers you to limit the number of connections to a particular port:

sudo ufw limit <port>/<protocol>

Optimal Security Practices

Uncomplicated Firewall (UFW) makes managing firewall rules simpler, making network security accessible to a wider audience. However, ensuring effective protection requires adopting best practices:

  1. Activate UFW to initiate security measures.
  2. Define rules based on your system’s requirements and services.
  3. Regularly review and update your firewall rules.
  4. Thoroughly test rules to confirm their intended functionality.

By mastering both UFW’s foundational and advanced features, you can protect your Linux system against potential threats and unauthorized access. UFW’s user-friendly approach makes network security accessible at any skill level.