Fail2ban is a popular security utility that automatically detects suspicious traffic and bans the IPs requesting them to your server. You can also customize its security rules as per your requirement. However, sometimes you may want to view banned IP in Fail2ban. In this article, we will learn how to show banned IP in Fail2ban.
How to Show Banned IP in Fail2ban
The easiest way to view banned IPs is to search for the keyword “Ban” or “Ban:” in Fail2ban log files. Open terminal and run the following command to do so.
$ sudo zgrep 'Ban' /var/log/fail2ban.log*
Or simply:
$ sudo fail2ban-client banned
If you want a count of banned IPs, pipe the output of above command to wc command, as shown below.
$ sudo zgrep 'Ban' /var/log/fail2ban.log* | wc -l
Alternatively, you can also view all iptables rules with the following command.
$ sudo iptables -L INPUT -v -n | less
In this short article, we have learnt how to list all banned IP addresses in Fail2ban.
Also read:
How to Unban IP with Fail2ban
NGINX Allow Local Network
How to Prevent Direct Access to Images in Apache
How to Prevent Direct Access to Images in NGINX
How to Know Which Shell I am Using in Linux
Related posts:
How to Overwrite Input File in Awk
How to Convert Permissions to Octal in Linux
How to Create Startup Disk for Ubuntu
How to Keep SSH Session Alive After Disconnect in Linux
How to Install Supervisor in RHEL/CentOS/Fedora
How to Install Dependencies with Apt
How to Return Value in Shell Script Function
How to Delete Write Protected File in Linux

Sreeram has more than 10 years of experience in web development, Python, Linux, SQL and database programming.
thanks
Or simply:
$ sudo fail2ban-client banned
Thank you for the feedback. We have updated the post accordingly.