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 Find Folder By Name in Linux
How to Save All Terminal Output to File
Fix "Too Many Authentication Failures" SSH Error
How to Copy Files from Linux to Windows
How to Change Mac Address in Linux
How to Compare Two Directories in Linux
How to Connect to MySQL Server via SSH Tunnel
Shell Script to Clear/Delete Log Files
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.