I have here a debian 10 with installed UFW. I want to know the user or uid of the processes of the connections which are logged by UFW. To log the UID I have add --log-uid
to the log rules in /etc/ufw/user.rules
:
### LOGGING ###
-A ufw-after-logging-input -j LOG --log-uid --log-prefix "[UFW BLOCK] " -m limit --limit 3/min --limit-burst 10
-A ufw-after-logging-output -j LOG --log-uid --log-prefix "[UFW BLOCK] " -m limit --limit 3/min --limit-burst 10
-A ufw-after-logging-forward -j LOG --log-uid --log-prefix "[UFW BLOCK] " -m limit --limit 3/min --limit-burst 10
-A ufw-logging-deny -m conntrack --ctstate INVALID -j LOG --log-uid --log-prefix "[UFW AUDIT INVALID] " -m limit --limit 3/min --limit-burst 10
-A ufw-logging-deny -j LOG --log-uid --log-prefix "[UFW BLOCK] " -m limit --limit 3/min --limit-burst 10
-A ufw-logging-allow -j LOG --log-uid --log-prefix "[UFW ALLOW] " -m limit --limit 3/min --limit-burst 10
-I ufw-before-logging-input -j LOG --log-uid --log-prefix "[UFW AUDIT] " -m conntrack --ctstate NEW -m limit --limit 3/min --limit-burst 10
-I ufw-before-logging-output -j LOG --log-uid --log-prefix "[UFW AUDIT] " -m conntrack --ctstate NEW -m limit --limit 3/min --limit-burst 10
-I ufw-before-logging-forward -j LOG --log-uid --log-prefix "[UFW AUDIT] " -m conntrack --ctstate NEW -m limit --limit 3/min --limit-burst 10
### END LOGGING ###
If I restart ufw (systemctl restart ufw
) and look into the /etc/ufw/user.rules
my added --log-uid
are still there. But after a while this option will be removed automatically and the UFW log output don't contains the UID. So my question is: What is the correct way to add the --log-uid
permanently?