Score:0

UFW not logging on fresh 20.04 install

us flag

I am not getting any UFW logs in /var/log/ufw.log.
I have tried everything on

to no avail. sudo dmesg | grep UFW does show me UFW logs, so they are ending up somewhere...

This is a fresh Ubuntu 20.04 install, just a stock OS install with a UFW installed via apt-get. Since I do see logs when grepping dmesg, but they are not going to any log I can find...

How do I find the log that's actually written to?

Score:0
in flag

Logging is generally not enabled with ufw by default because the files can get very big, very quickly. That said, if you would like to enable the logs, you can do so like this:

sudo ufw logging on

From here, you'll see ufw.log file in /var/log that rotates with the same schedule as the rest of the files in that directory.

One thing to note is that the logging level is set to low by default. Depending on how verbose you would like the logs to be, you can change the setting like this:

sudo ufw logging medium

The different levels as outlined in the manual:

Option Verbosity
off disables ufw managed logging
low logs all blocked packets not matching the defined policy (with rate limiting), as well as packets matching logged rules
medium log level low, plus all allowed packets not matching the defined policy, all INVALID packets, and all new connections. All logging is done with rate limiting.
high log level medium (without rate limiting), plus all packets with rate limiting
full log level high without rate limiting

Note that if you do want to keep all of the UFW logs on a heavily-trafficked web server (500+ requests per minute), you will want to ensure /var/log is on a flash-based storage device and ideally has about 20GB of free space with a log shipping plan in place to move rotated logs off the machine.

Seamus avatar
us flag
Logging is on but I still get no logs written. Thanks for the tip on growth, I dont plan on persisting them, I just want to have fail2ban watch them to block port scanning. # ufw status verbose Status: active Logging: on (low) Default: deny (incoming), allow (outgoing), deny (routed) New profiles: skip
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.