How to Install & Configure UFW Firewall on Arch Linux
If you’re running Arch and want a no‑frills firewall that actually works out of the box, this guide will get UFW up and running in under ten minutes. I’ll walk through pulling the package from pacman, tweaking the rules so they make sense for a desktop, and showing how to keep the service alive after a reboot.
Install the package
sudo pacman -S ufw
UFW lives in the official repos, so you don’t need any AUR gymnastics. The install pulls in iptables as a dependency, which is what actually does the packet filtering under the hood.
Enable and start the service
sudo systemctl enable --now ufw.service
Enabling it at boot saves you from having to remember “did I forget the firewall today?” later. The --now flag also starts it immediately so you can test right away.
Set a sane default policy
sudo ufw default deny incoming
sudo ufw default allow outgoing
Arch is often used for custom setups, and the default‑allow‑all stance that ships with most desktop distros is a recipe for surprise traffic. Denying inbound connections by default blocks everything you haven’t explicitly allowed—no more “why is my SSH port open?” headaches.
Open the ports you actually need
sudo ufw allow ssh # 22/tcp
sudo ufw allow http # 80/tcp
sudo ufw allow https # 443/tcp
I’ve seen people reinstall Arch after a kernel panic caused by a rogue driver, only to discover the real culprit was an open telnet port they’d forgotten about. Explicitly allowing just the services you use keeps the attack surface tiny.
If you run a local development server on a non‑standard port, just add it:
sudo ufw allow 8080/tcp
Verify the rule set
sudo ufw status verbose
The output lists each rule and shows whether the firewall is active. If you spot something odd—like “allow from any to any” that you didn’t create—run sudo ufw reset and start over.
Optional: tweak logging
sudo ufw logging on
UFW logs dropped packets to /var/log/ufw.log. Turn it on if you like watching the occasional “blocked” line in real time; turn it off if you’re low on disk space. I keep it on a home box because it’s useful when troubleshooting a new program that suddenly refuses network access.
Common pitfalls
- Forgot to reload after editing /etc/ufw/before.rules – changes won’t take effect until you run sudo ufw reload.
- Running another firewall simultaneously – having both firewalld and UFW active creates conflicting iptables chains. Disable the other service with systemctl disable --now firewalld.service.
That’s it—UFW on Arch is a lightweight gatekeeper that doesn’t get in your way but still stops the usual noise from the internet. Give it a spin, add or remove rules as you see fit, and enjoy the peace of mind that comes with knowing only the traffic you’ve approved gets through.