How to get list of all currently banned IP addresses with Fail2ban

Use below command to get list of all currently banned IP addresses with Fail2ban

$ sudo fail2ban-client status | grep "Jail list:" | sed "s/ //g" | awk '{split($2,a,",");for(i in a) system("sudo fail2ban-client status " a[i])}' | grep "Status\|IP list"

This will give list of output in below format

Status for the jail: sshd
   `- Banned IP list: XX.XX.XX.XX
Status for the jail: Any other service for which Fail2ban is enabled
   `- Banned IP list: XX.XX.XX.XX, YY.YY.YY.YY

With this command you will get list of P addresses currently banned for all services for which Fail2ban is enabled. To get list of all banned IP addresses including previously banned, please see How to get list of all IP addresses banned with Fail2ban