How to Read Fail2Ban Logs: Ban Entries, Status Commands and Unban

Sunucun 4 min read

Fail2Ban is a tool that finds suspicious repeated events in server logs (for example SSH login attempts) and temporarily blocks the IP address responsible with the firewall. It writes to its own log file when, by which rule (jail) and which IP it blocked. Reading these records is necessary to see attacks, to find an IP that was blocked by mistake and to confirm that the rules work.

Illustration: Fail2Ban

Where Is the Fail2Ban Log File?

On most distributions (Debian, Ubuntu and CentOS/AlmaLinux packages), the default location is /var/log/fail2ban.log. The location is set by the logtarget option in /etc/fail2ban/fail2ban.conf; if you want to change it, create /etc/fail2ban/fail2ban.local and put the setting there instead of editing the original file. If logging is directed to the system journal, read it with journalctl -u fail2ban.

# Last 50 lines
sudo tail -n 50 /var/log/fail2ban.log
# Follow live
sudo tail -f /var/log/fail2ban.log
# From the systemd journal
sudo journalctl -u fail2ban --since today

What Do the Log Lines Mean?

A typical record looks like this:

2026-11-10 14:02:11,384 fail2ban.filter  [812]: INFO    [sshd] Found 203.0.113.25 - 2026-11-10 14:02:11
2026-11-10 14:02:15,901 fail2ban.actions [812]: NOTICE  [sshd] Ban 203.0.113.25
2026-11-10 14:12:15,477 fail2ban.actions [812]: NOTICE  [sshd] Unban 203.0.113.25
PartMeaning
Date and timeWhen the event happened
fail2ban.filter / fail2ban.actionsThe component that wrote the record: the filter finds matches, actions bans or unbans
[812]The process ID (PID) of Fail2Ban
INFO, NOTICE, WARNING, ERRORLog level
[sshd]The jail (rule set) that triggered the event
FoundThe filter found a suspicious line for the IP (no ban yet)
BanThe IP reached maxretry within findtime and was blocked
Unbanbantime expired and the block was removed
already bannedAn IP that is already blocked matched again

Useful Search Commands

# Ban records only
sudo grep " Ban " /var/log/fail2ban.log
# Top 10 most banned IPs
sudo grep " Ban " /var/log/fail2ban.log | awk '{print $NF}' | sort | uniq -c | sort -rn | head
# History of a specific IP
sudo grep "203.0.113.25" /var/log/fail2ban.log
# Search rotated (compressed) old logs
sudo zgrep " Ban " /var/log/fail2ban.log*
# Errors and warnings
sudo grep -E "ERROR|WARNING" /var/log/fail2ban.log

Seeing Banned IPs: fail2ban-client status

The log file shows the history; to see which IPs are banned right now, use fail2ban-client:

# List of active jails
sudo fail2ban-client status
# Status of the sshd jail: currently banned count, total bans and IP list
sudo fail2ban-client status sshd
# Unban an IP
sudo fail2ban-client set sshd unbanip 203.0.113.25

In the status sshd output, Currently failed shows the number of matches, Currently banned the number of IPs banned right now and Banned IP list the banned addresses. The File list line shows which log file the jail is watching; if the file you expect is not there, the jail will not catch anything.

What to Look for in the Log

  • If there are no Ban lines at all: check whether the jail is enabled (fail2ban-client status), whether the watched log path is correct and whether the filter really matches the lines. To test a filter: fail2ban-regex /var/log/auth.log /etc/fail2ban/filter.d/sshd.conf.
  • If your own IP was banned: remove it with unbanip and add your IP to the ignoreip list.
  • If the same IP keeps coming back: consider a longer bantime, or the bantime.increment option, which applies longer bans to repeat offenders.
  • ERROR lines: usually mean that the firewall command (iptables, nftables, firewalld) did not work or that a log file could not be found.

For installation and basic settings, see our articles installing Fail2Ban and Fail2Ban settings, and for the attacks it protects against, which attacks Fail2Ban blocks. To install Fail2Ban on a server with root access, take a look at our VDS servers.

Frequently Asked Questions

What is the difference between the Fail2Ban log and auth.log?

auth.log (/var/log/secure on RHEL-based systems) records the SSH login attempts themselves, while fail2ban.log records Fail2Ban’s response to those attempts (Found, Ban, Unban).

The log file has grown very large; can I delete it?

Instead of deleting the file by hand, let logrotate rotate it; the packages usually come with a logrotate configuration for this. Old files are kept with extensions such as .1 and .2.gz.

Categories

Latest guides