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 Merge Folders & Directories in Linux
How to Parse CSV File in Shell
How to Run MySQL Query from Command Line
How to Resolve Unmet Dependencies in Ubuntu
SCP command in Linux to copy file from one server to another
How to Generate & Verify MD5 Hash of File in Linux
How to Copy Files from Linux to S3 bucket
How to Manage Systemd Services on Remote Linux Systems

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.