Linux Commands

How Do I Check My UFW Log?

This tutorial explains how to enable UFW (Uncomplicated Firewall) logging and how to read the logs. A firewall is critical to maintain security on your linux and ubuntu systems.

After reading this tutorial, you will know how to find and read UFW logs. For a complete UFW tutorial, you can read Working with Debian Firewalls (UFW).

To begin, you can enable UFW with the status verbose option to check if logging is enabled or disabled. Run the command below:

sudo ufw status verbose

As you can see, logging is disabled (off). To enable logging on UFW, run the command below:

sudo ufw logging on

As you can see, logging has been enabled.

If you want to recheck it, run the ufw status verbose again as shown below:

sudo ufw status verbose

As you can see, logging is enabled, and between parentheses, you can read (low). This is because there are five different logging levels:

  • Off: No managed logging.
  • On (low): Logs all blocked or allowed packets by defined policies.
  • On (medium): Same as above, and additionally, it includes packets not matching policies.
  • On (High): Logs all rate-limiting and without rate limiting.
  • On (Full): Logs all packets without rate limiting.

For example, if you want to change the logging level to medium, you can run the command below.

sudo ufw logging medium

Note: In the command above, replace medium with another value for a different logging level.

Usually, logs are stored under the /var/log/ directory, and UFW isn’t the exception. To see UFW available logs, you can use the ls command and a to implement a wildcard, as shown in the following example.

sudo ls /var/log/ufw*;

As you can see, there are several UFW Logs. Let’s see how to read and interpret them.

Note: for UFW logging to work, rsyslog must be enabled. You can check it by running the command below:

service rsyslog status

To simply read all logs without parameters, you can run:

sudo less /var/log/ufw*

As you can see, there are many fields, and the following list provides each field’s meaning.

  • IN= This field shows the device for incoming traffic.
  • OUT= This field shows the device for outgoing traffic.
  • MAC= This field shows the device’s MAC address.
  • SRC= This field displays a connection source IP address.
  • DST= Displays the destination IP address of a connection.
  • LEN= This field shows the packet’s length.
  • TOS= (Type of Service) This field is used for packet classification, and it is deprecated.
  • PREC= This field shows the Precedence Type of Service.
  • TTL= This field shows Time To Live.
  • ID= This field shows a unique ID for the IP datagram, which is shared by fragments of the same packet.
  • PROTO= This field shows the used protocol.

To read the last log entries, run the following command:

sudo tail -f /var/log/ufw.log

The new fields SPT and DPT, which were not explained previously, show the source and destination ports.

A different command to read UFW logs using grep would be:

grep -i ufw /var/log/syslog

Or the following command:

grep -i ufw /var/log/messages

You also can run:

grep -i ufw /var/log/kern.log


UFW is the easiest CLI firewall front-end for Iptables in the market. Using it is even faster and simpler than using any other firewall, including GUI software. Some users ignore the logging feature, and it must be enabled and properly configured to get correct logs from UFW. It is also important to remember rsyslog must be enabled for this feature to work.

As you can see, UFW allows us to manage the verbosity level, and it provides a very detailed report on connections. UFW is an excellent tool for non-advanced users to control their network traffic and protect their system by implementing rules or actions with an easy syntax. Learning to use this Iptables front-end is a great way for new users to be introduced into the firewalls world before going through Iptables and Netfilter. UFW has a simple GUI interface (GUFW) to apply rules and actions and manage your firewall, despite the CLI version being even easier to use for any Linux user level.

I hope this tutorial explaining how to check UFW logs was useful. Keep following Linux Hint for more Linux tips and tutorials.

About the author

David Adams

David Adams is a System Admin and writer that is focused on open source technologies, security software, and computer systems.