Where Are UFW Firewall Rules Stored?
UFW user rules live in user.rules and user6.rules under firewall config folders. Manage them with ufw commands rather than direct edits.
Last updated
UFW stores IPv4 and IPv6 user rules in user.rules and user6.rules. Base settings live in ufw.conf and default files alongside them.
Exact base folder varies slightly by release between /etc/ufw and /lib/ufw. The ufw command keeps paired files in sync, so manual edits can be overwritten or rejected.
Where UFW stores this, by platform
/etc/ufw/user.rules
Active IPv4 user rules on current Ubuntu releases. Older releases show the same data under /lib/ufw/user.rules. Needs root to read. Edit with ufw allow, deny, delete and reload rather than a text editor.
/etc/ufw/user6.rules
Active IPv6 user rules when IPv6 is enabled in /etc/default/ufw. Same handling as the IPv4 file. Disabled IPv6 leaves this file unused.
/etc/ufw/ufw.conf
Main enable flag and log level. See also /etc/default/ufw for IPv6 and default policy knobs. Check ufw status verbose to confirm running state after changes.
Frequently asked questions
Why do my manual edits to user.rules vanish?
UFW rewrites those files on reload and rule changes. Apply changes with ufw commands, then verify with status output.
Where are app profiles and before rules?
App definitions live in /etc/ufw/applications.d. Ordering hooks live in before.rules and after.rules. Custom iptables additions belong in those framework files, not in user.rules.
Notice an outdated path? Let us know.