Site icon CentLinux

Quick install UFW Firewall in Arch Linux

Share on Social Media

Learn how to install UFW Firewall in Arch Linux and then configure it with our step-by-step guide. Secure your system by managing firewall rules easily with UFW. #centlinux #linux #firewall



Introduction to UFW Firewall

What is UFW?

UFW (Uncomplicated Firewall) is a powerful yet user-friendly frontend designed to simplify the management of iptables firewall rules in Linux. It provides an intuitive interface that allows users to easily configure firewall settings without needing in-depth knowledge of complex iptables commands.

By streamlining the process, UFW makes it effortless to secure your system, control network traffic, and enforce security policies with just a few simple commands. Whether you are a beginner or an advanced user, UFW ensures that managing firewall rules remains straightforward and efficient, helping to enhance the overall security of your Linux system.

How to install UFW in Arch Linux

Why Use UFW on Arch Linux?

Arch Linux is well-known for its flexibility and powerful network security tools, but configuring firewall rules directly through iptables can be complex and time-consuming, especially for beginners. This is where UFW (Uncomplicated Firewall) comes in, providing a simplified and user-friendly approach to firewall management. With UFW, users can easily allow or block specific connections using straightforward commands, eliminating the need to manually handle intricate iptables rules.

By enabling UFW on your Arch Linux system, you can enhance security by restricting unauthorized access, blocking unwanted traffic, and ensuring that only necessary and trusted connections are allowed. Whether you’re managing a personal system or a server, UFW offers an efficient way to protect your network while maintaining full control over inbound and outbound traffic. With its ease of use and effectiveness, UFW is an excellent choice for both novice and experienced Linux users who want a hassle-free yet robust firewall solution.

Recommended Training: Linux Administration: The Complete Linux Bootcamp in 2025 from Andrei Dumitrescu, Crystal Mind Academy


Prerequisites

System Requirements

Before installing UFW, ensure that:

Updating the System Before Installation

Before installing UFW, update your system packages to avoid dependency issues:

sudo pacman -Syu

This ensures that all packages, including dependencies for UFW, are up-to-date.


Install UFW on Arch Linux

Installing UFW Using Pacman

UFW (Uncomplicated Firewall) is readily available in Arch Linux’s official repositories, making it easy to install without the need for third-party sources or manual compilation. Since it is officially maintained, you can be assured of receiving the latest updates, security patches, and improvements directly from Arch’s package management system.

To install UFW on your Arch Linux system, simply use the pacman package manager, which is the default package management tool for Arch. Open a terminal and run the following command:

sudo pacman -S ufw

Verifying the Installation

After installation, verify that UFW is installed by checking its version:

ufw --version

If the installation is successful, the command will output the UFW version number.

Read Also: EndeavourOS – An Arch-Based Linux Distro


Enabling and Starting UFW

Checking UFW Status

Before enabling UFW on your Arch Linux system, it’s important to check its current status to determine whether it is already active or disabled. This step ensures that you are aware of any existing firewall rules and configurations before making changes. Running a status check will provide you with valuable information, such as whether UFW is enabled, which rules are currently applied, and how the firewall is handling incoming and outgoing connections.

To check the current status of UFW, open a terminal and run the following command:

sudo ufw status

By default, UFW is disabled.

Enabling UFW on System Boot

To enable and start UFW, use:

sudo systemctl enable ufw
sudo systemctl start ufw

Verify that UFW is active:

sudo systemctl status ufw

If UFW is running, you’ll see an output indicating that the service is “active (running).”


Basic UFW Commands and Usage

Allowing and Denying Connections

Once UFW is installed and enabled, you need to configure it to allow or deny connections.

Allow SSH access (Port 22):

sudo ufw allow ssh

Allow HTTP (Port 80):

sudo ufw allow 80/tcp

Allow HTTPS (Port 443):

sudo ufw allow 443/tcp

Allow a specific port (e.g., Port 8080):

sudo ufw allow 8080

Deny a specific port:

sudo ufw deny 8080

Allow a specific IP address to access all ports:

sudo ufw allow from 192.168.1.100

Deny a specific IP address:

sudo ufw deny from 192.168.1.200

Checking Firewall Rules

To check which rules are currently applied, use:

sudo ufw status verbose

This command provides detailed information on allowed and denied connections.


Advanced UFW Configuration

Enabling Logging

Enabling logging in UFW allows you to monitor firewall activity, track incoming and outgoing traffic, and identify any potential security threats or unauthorized access attempts. By keeping detailed logs, you can analyze which connections are being blocked or allowed, helping you fine-tune your firewall rules for better security and performance.

Firewall logs are particularly useful for troubleshooting network issues, auditing security policies, and ensuring that your system is protected against malicious traffic. To enable logging in UFW and start monitoring firewall activity, use the following command:

sudo ufw logging on

You can check the logs in:

sudo tail -f /var/log/ufw.log

Setting Default Policies

By default, UFW blocks incoming connections and allows outgoing ones. You can manually set these policies:

Deny all incoming connections:

sudo ufw default deny incoming

Allow all outgoing connections:

sudo ufw default allow outgoing

If you want to block all outgoing connections and allow only specific ones, you can modify these settings accordingly.


Allowing and Blocking Specific Services

Allowing SSH, HTTP, HTTPS

If you’re running a web server, ensure that HTTP (port 80) and HTTPS (port 443) are open:

sudo ufw allow http
sudo ufw allow https

If you’re accessing the server remotely via SSH, ensure SSH is allowed:

sudo ufw allow ssh

Blocking Unwanted Ports

If a certain port is not in use and you want to block it:

sudo ufw deny 9999

If you want to block all connections from a specific IP range:

sudo ufw deny from 192.168.1.0/24

This ensures that no devices from this IP range can access your system.

Read Also: How to Install LAMP Stack on Arch Linux


Managing UFW Profiles

Creating Custom Rules

If you need to create a more specific rule, use the following format:

sudo ufw allow from 192.168.1.100 to any port 22

This allows only the specific IP 192.168.1.100 to access SSH.

Deleting and Resetting Rules

To delete a rule, first list the rules with:

sudo ufw status numbered

Then, delete the rule by specifying its number:

sudo ufw delete <rule_number>

To reset UFW to default settings:

sudo ufw reset

Disabling and Resetting UFW

Disabling UFW Temporarily

If you need to disable UFW temporarily, run:

sudo ufw disable

To re-enable it:

sudo ufw enable

Resetting UFW to Default Settings

If your firewall rules are misconfigured and you need to start fresh:

sudo ufw reset

This will disable UFW and remove all existing rules.


Troubleshooting UFW on Arch Linux

Checking Logs for Errors

If you suspect UFW is not working properly, check its logs:

sudo journalctl -u ufw --no-pager | tail -20

Common Issues and Fixes

1. Issue: SSH Connection Lost After Enabling UFW

Solution: Ensure SSH is allowed before enabling UFW:

sudo ufw allow ssh

2. Issue: UFW Not Starting on Boot

Solution: Enable UFW to start on boot:

sudo systemctl enable ufw

3. Issue: UFW Blocking Outgoing Traffic

Solution: Check default policies:

sudo ufw status verbose

If needed, allow outgoing traffic:

sudo ufw default allow outgoing

Video Tutorial

To help you better understand the process of installing and configuring UFW on Arch Linux, we’ve included a detailed video tutorial that walks you through each step. This tutorial provides a hands-on demonstration of installing UFW, enabling it, setting up essential firewall rules, and troubleshooting common issues. Whether you’re a beginner or an experienced Linux user, this video will make it easier to follow along and implement UFW on your system. Watch the tutorial now and enhance your network security effortlessly!


Conclusion

UFW is a powerful yet easy-to-use firewall tool that enhances the security of your Arch Linux system. By properly configuring UFW, you can block unwanted access while allowing necessary services to function smoothly. Whether you’re a beginner or an advanced user, UFW provides a simple way to manage firewall rules effectively.

Whether you need cloud optimization, server management, or automation, I provide comprehensive AWS and Linux services. Hire me on Fiverr to elevate your systems.


FAQs

1. Is UFW enabled by default in Arch Linux?

No, UFW is not enabled by default. You need to install and enable it manually using sudo pacman -S ufw followed by sudo ufw enable.

2. How can I check if UFW is running?

You can check the status of UFW using:

sudo ufw status

If it says “inactive,” UFW is not running.

3. How do I reset UFW rules?

To reset all UFW rules to default settings, use:

sudo ufw reset

4. Can UFW block specific IP addresses?

Yes, you can block an IP address using:

sudo ufw deny from 192.168.1.100

5. How do I allow only a specific IP to access my server?

Use the following command:

sudo ufw allow from <IP_ADDRESS>

For example, to allow 192.168.1.50 to access all ports:

sudo ufw allow from 192.168.1.50
Exit mobile version