Where does UFW (uncomplicated firewall) save command-line rules to?

You add a rule like this:

ufw allow 22/tcp

The rule is saved, and is applied even after reboot. But it's not written anywhere in /etc/ufw. Where is it saved to? (Ubuntu, using ufw as pre-installed.)


Solution 1:

In my Ubuntu 11 server, the firewall rules are saved in /lib/ufw/user.rules

Solution 2:

Ubuntu 16.04 LTS

/etc/ufw/user.rules

Debian 9

/etc/ufw/user.rules

In general, try:

locate user.rules

Should output something like:

/etc/ufw/user.rules
/usr/share/ufw/user.rules
/usr/share/ufw/user.rules.md5sum
/usr/share/ufw/iptables/user.rules

Solution 3:

I believe it's under lib/ufw/rules[6].rules