{"id":9856,"date":"2024-03-30T23:02:30","date_gmt":"2024-03-30T20:02:30","guid":{"rendered":"https:\/\/sunucun.com.tr\/bilgi\/?post_type=dt_articles&#038;p=9856"},"modified":"2026-11-15T22:57:05","modified_gmt":"2026-11-15T19:57:05","slug":"how-to-read-fail2ban-logs","status":"publish","type":"post","link":"https:\/\/sunucun.com.tr\/blog\/how-to-read-fail2ban-logs\/","title":{"rendered":"How to Read Fail2Ban Logs: Ban Entries, Status Commands and Unban"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><strong>Fail2Ban<\/strong> 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 <strong>log file<\/strong> 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.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Where Is the Fail2Ban Log File?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">On most distributions (Debian, Ubuntu and CentOS\/AlmaLinux packages), the default location is <code>\/var\/log\/fail2ban.log<\/code>. The location is set by the <code>logtarget<\/code> option in <code>\/etc\/fail2ban\/fail2ban.conf<\/code>; if you want to change it, create <code>\/etc\/fail2ban\/fail2ban.local<\/code> and put the setting there instead of editing the original file. If logging is directed to the system journal, read it with <code>journalctl -u fail2ban<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Last 50 lines\nsudo tail -n 50 \/var\/log\/fail2ban.log\n# Follow live\nsudo tail -f \/var\/log\/fail2ban.log\n# From the systemd journal\nsudo journalctl -u fail2ban --since today<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">What Do the Log Lines Mean?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A typical record looks like this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>2026-11-10 14:02:11,384 fail2ban.filter  [812]: INFO    [sshd] Found 203.0.113.25 - 2026-11-10 14:02:11\n2026-11-10 14:02:15,901 fail2ban.actions [812]: NOTICE  [sshd] Ban 203.0.113.25\n2026-11-10 14:12:15,477 fail2ban.actions [812]: NOTICE  [sshd] Unban 203.0.113.25<\/code><\/pre>\n\n\n\n<div class=\"snc-table-wrap\"><table>\n<thead><tr><th>Part<\/th><th>Meaning<\/th><\/tr><\/thead>\n<tbody>\n<tr><td>Date and time<\/td><td>When the event happened<\/td><\/tr>\n<tr><td><code>fail2ban.filter<\/code> \/ <code>fail2ban.actions<\/code><\/td><td>The component that wrote the record: the filter finds matches, actions bans or unbans<\/td><\/tr>\n<tr><td><code>[812]<\/code><\/td><td>The process ID (PID) of Fail2Ban<\/td><\/tr>\n<tr><td><code>INFO<\/code>, <code>NOTICE<\/code>, <code>WARNING<\/code>, <code>ERROR<\/code><\/td><td>Log level<\/td><\/tr>\n<tr><td><code>[sshd]<\/code><\/td><td>The jail (rule set) that triggered the event<\/td><\/tr>\n<tr><td><code>Found<\/code><\/td><td>The filter found a suspicious line for the IP (no ban yet)<\/td><\/tr>\n<tr><td><code>Ban<\/code><\/td><td>The IP reached <code>maxretry<\/code> within <code>findtime<\/code> and was blocked<\/td><\/tr>\n<tr><td><code>Unban<\/code><\/td><td><code>bantime<\/code> expired and the block was removed<\/td><\/tr>\n<tr><td><code>already banned<\/code><\/td><td>An IP that is already blocked matched again<\/td><\/tr>\n<\/tbody><\/table><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Useful Search Commands<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code># Ban records only\nsudo grep \" Ban \" \/var\/log\/fail2ban.log\n# Top 10 most banned IPs\nsudo grep \" Ban \" \/var\/log\/fail2ban.log | awk '{print $NF}' | sort | uniq -c | sort -rn | head\n# History of a specific IP\nsudo grep \"203.0.113.25\" \/var\/log\/fail2ban.log\n# Search rotated (compressed) old logs\nsudo zgrep \" Ban \" \/var\/log\/fail2ban.log*\n# Errors and warnings\nsudo grep -E \"ERROR|WARNING\" \/var\/log\/fail2ban.log<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Seeing Banned IPs: fail2ban-client status<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The log file shows the history; to see which IPs are banned right now, use <code>fail2ban-client<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># List of active jails\nsudo fail2ban-client status\n# Status of the sshd jail: currently banned count, total bans and IP list\nsudo fail2ban-client status sshd\n# Unban an IP\nsudo fail2ban-client set sshd unbanip 203.0.113.25<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In the <code>status sshd<\/code> output, <strong>Currently failed<\/strong> shows the number of matches, <strong>Currently banned<\/strong> the number of IPs banned right now and <strong>Banned IP list<\/strong> the banned addresses. The <strong>File list<\/strong> line shows which log file the jail is watching; if the file you expect is not there, the jail will not catch anything.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What to Look for in the Log<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>If there are no Ban lines at all:<\/strong> check whether the jail is enabled (<code>fail2ban-client status<\/code>), whether the watched log path is correct and whether the filter really matches the lines. To test a filter: <code>fail2ban-regex \/var\/log\/auth.log \/etc\/fail2ban\/filter.d\/sshd.conf<\/code>.<\/li>\n<li><strong>If your own IP was banned:<\/strong> remove it with <code>unbanip<\/code> and add your IP to the <code>ignoreip<\/code> list.<\/li>\n<li><strong>If the same IP keeps coming back:<\/strong> consider a longer <code>bantime<\/code>, or the <code>bantime.increment<\/code> option, which applies longer bans to repeat offenders.<\/li>\n<li><strong>ERROR lines:<\/strong> usually mean that the firewall command (iptables, nftables, firewalld) did not work or that a log file could not be found.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">For installation and basic settings, see our articles <a href=\"https:\/\/sunucun.com.tr\/blog\/how-to-set-up-fail2ban\/\">installing Fail2Ban<\/a> and <a href=\"https:\/\/sunucun.com.tr\/blog\/how-to-set-fail2ban-settings\/\">Fail2Ban settings<\/a>, and for the attacks it protects against, <a href=\"https:\/\/sunucun.com.tr\/blog\/which-attacks-does-fail2ban-block\/\">which attacks Fail2Ban blocks<\/a>. To install Fail2Ban on a server with root access, take a look at our <a href=\"https:\/\/sunucun.com.tr\/en\/vds-server\">VDS servers<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Frequently Asked Questions<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">What is the difference between the Fail2Ban log and auth.log?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><code>auth.log<\/code> (<code>\/var\/log\/secure<\/code> on RHEL-based systems) records the SSH login attempts themselves, while <code>fail2ban.log<\/code> records Fail2Ban&#8217;s response to those attempts (Found, Ban, Unban).<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">The log file has grown very large; can I delete it?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">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 <code>.1<\/code> and <code>.2.gz<\/code>.<\/p>\n\n","protected":false},"excerpt":{"rendered":"<p>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&hellip;<\/p>\n","protected":false},"author":1,"featured_media":9853,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[1519],"tags":[],"class_list":["post-9856","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-sanal-sunucu"],"_links":{"self":[{"href":"https:\/\/sunucun.com.tr\/blog\/wp-json\/wp\/v2\/posts\/9856","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sunucun.com.tr\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sunucun.com.tr\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sunucun.com.tr\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sunucun.com.tr\/blog\/wp-json\/wp\/v2\/comments?post=9856"}],"version-history":[{"count":1,"href":"https:\/\/sunucun.com.tr\/blog\/wp-json\/wp\/v2\/posts\/9856\/revisions"}],"predecessor-version":[{"id":19918,"href":"https:\/\/sunucun.com.tr\/blog\/wp-json\/wp\/v2\/posts\/9856\/revisions\/19918"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/sunucun.com.tr\/blog\/wp-json\/wp\/v2\/media\/9853"}],"wp:attachment":[{"href":"https:\/\/sunucun.com.tr\/blog\/wp-json\/wp\/v2\/media?parent=9856"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sunucun.com.tr\/blog\/wp-json\/wp\/v2\/categories?post=9856"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sunucun.com.tr\/blog\/wp-json\/wp\/v2\/tags?post=9856"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}