Linux

Where Does UFW Store Firewall Rules?

UFW keeps firewall rules in /etc/ufw with user rules in user.rules. Enable with ufw enable; check status with ufw status verbose.

Last updated

UFW fronts iptables with human-readable rules. User rules accumulate in the user rules file under /etc/ufw, with defaults and application profiles beside them. The enable command flips the whole set live.

Rule order matters more than newcomers expect: first match wins, so specific allows precede broad denies. IPv6 gets its own parallel handling controlled by a single config toggle. Before enabling remotely, set a timed fallback or keep a console session open; everyone locks themselves out exactly once, usually at midnight before a deadline.

Where UFW Firewall stores this, by platform

Linux
/etc/ufw/user.rules

User rules plus defaults and app profiles here. Needs root to edit. Confirm console access before first enable on remote servers.

Frequently asked questions

What is a safe first UFW setup?

Deny incoming by default, then allow only needed ports like SSH, HTTP, and HTTPS. Enable logging at low level to watch blocked probes. On cloud servers, confirm console access first; a default-deny without an SSH rule locks you out.

How do I migrate UFW rules?

Copy the rules files to the new machine with matching paths, then reload. Application profiles under applications.d travel too when custom apps are involved. Verify with status verbose before leaving; rule order decides matches.

Notice an outdated path? Let us know.