40

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.)

  • wow, I leaned something new today. "uncomplicated firewall" – answerSeeker Feb 21 '18 at 3:39
44

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

  • 2
    Bingo, thanks. There's also a user6.rules (which doesn't have all the rules I created, but otherwise looks similar). – Steve Bennett Feb 13 '13 at 8:20
  • 2
    user6.rules is for IP version 6 (ipv6) firewall rules. – Daniel t. Feb 13 '13 at 14:41
  • 1
    Still correct in Ubuntu 14, thank you. – Nick Triantafillou Aug 27 '15 at 1:24
  • 5
    What a crazy location! I just spent 20 minutes looking for this :-( – reinierpost Dec 2 '15 at 16:48
18

Ubuntu 16.04 LTS

/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
  • 1
    It's recommended to run updatedb at least once before using locate. – ccpizza Jan 15 '17 at 19:44
9

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

3

In my version, 8.04 LTS Server the files are stored in /var/lib/ufw as /var/lib/ufw/user.rules and /var/lib/ufw/user6.rules.

1

This should work on all Linux systems assuming a ".rules" suffix and residing beneath a directory named "ufw":

sudo find / -name "*.rules" -exec ls -l {} \; | grep ufw

Using the "ls -l" shows that some of them are links to others, and which ones have been updated most recently (implying they are active?)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.