How to get list of all IP addresses banned today by Fail2ban

List of all IP addresses banned today by Fail2ban:

sudo zgrep -h "Ban " /var/log/fail2ban.log* | grep `date +%Y-%m-%d` | awk '{print $NF}' | sort | uniq -c

To sort in ascending order by count of ban, use below command

sudo zgrep -h "Ban " /var/log/fail2ban.log* | grep `date +%Y-%m-%d` | awk '{print $NF}' | sort | uniq -c | sort -n

List of all IP addresses banned today by Fail2ban, grouped by IP address and Hostname:

Logresolve command is not installed by default, you have to install logresolve before running this command

sudo zgrep -h "Ban " /var/log/fail2ban.log* | grep `date +%Y-%m-%d` | awk '{print $NF}' | sort | awk '{print $1,"("$1")"}' | logresolve | uniq -c

To sort in ascending order by count of ban, use below command

sudo zgrep -h "Ban " /var/log/fail2ban.log* | grep `date +%Y-%m-%d` | awk '{print $NF}' | sort | awk '{print $1,"("$1")"}' | logresolve | uniq -c | sort -n

If you want to get list of all IP addresses ever banned by Fail2ban, then please follow steps mentioned on How to get list of all IP addresses banned by Fail2ban

More more ways to analyse Fail2ban logs, please visit Fail2ban Log Analysis