Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Show status of all fail2ban jails at once
JAILS=`fail2ban-client status | grep "Jail list" | sed -E 's/^[^:]+:[ \t]+//' | sed 's/,//g'`
for JAIL in $JAILS
fail2ban-client status $JAIL
Copy link

artfulrobot commented Oct 19, 2014

Thanks! can't believe there isn't a fail2ban-client status --all command!

Copy link

mattgorecki commented Dec 19, 2016

Excellent! It was -e for me on Centos 6.

Copy link

xrobin commented Jan 19, 2017

On a SLES box I had to use lowercase -e as well, and escape the + signs in the regex

JAILS=`fail2ban-client status | grep "Jail list" | sed -e 's/^[^:]\+:[ \t]\+//' | sed 's/,//g'`

Copy link

caic commented Jan 31, 2017

Thank you! It works on Ubuntu 16.04.

Copy link

acosonic commented Feb 22, 2017

Thank you! Also confirming works on Ubuntu 16.04

Copy link

maravedi commented Mar 8, 2017

This is perfect 👍

Copy link

ahmadawais commented Apr 24, 2017

Copy link

shlublu commented Jul 6, 2017

It has been said already, but many thanks (Ubuntu 16.04)! :)

Copy link

kofran commented Aug 16, 2017

Thanks so much

Copy link

welrbraga commented Dec 7, 2017

Why make it easy if you can do hard? :-)

fail2ban-client status|awk -F: '/Jail list:/ { split($2,jail,",") ; for (i in jail) { gsub(/[\t ]/,"",jail[i]); system("fail2ban-client status "jail[i]); }; }'

Copy link

joergludwig commented Dec 20, 2017

Shorter version:
fail2ban-client status | sed -n 's/,//g;s/.*Jail list://p' | xargs -n1 fail2ban-client status

Copy link

Fieel commented Jan 17, 2018

Nice! Will use this script in my server, ty again <3

Copy link

VA2PE commented Feb 9, 2018

Thanks, works well on CentOS 7.

Copy link

vkostyuk commented Aug 8, 2018

Nice. Needs sudo, so sudo sh -c "fail2ban-client status | sed -n 's/,//g;s/.*Jail list://p' | xargs -n1 fail2ban-client status"

Copy link

placecodex commented Sep 2, 2018

1# sudo apt-get remove fail2ban : remove the packet
2# sudo rm -rf fail2ban : delete fail2ban folder
3# re install again

Copy link

stefan1959 commented Jul 26, 2019

doesn't ipset list do this?

Copy link

kamermans commented Jul 28, 2019

@stefan1959 I don't know, although this post was over 5 years ago, so things have probably changed!

Copy link

kangarooo commented Mar 12, 2020


Copy link

Wepted commented Dec 21, 2020

thank you

Copy link

stueja commented Feb 15, 2021

Thank you!

Copy link

deybin7 commented Mar 19, 2021

Thank you pal!

Copy link

jsagarino commented Apr 7, 2021

Thanks man!

Copy link

lls-hcr commented May 21, 2021

Very handy, thank you

Copy link

tmsBodnar commented Jul 18, 2021


Copy link

Ravinou commented Jan 14, 2022

Thanks !

Copy link

biesior commented Sep 23, 2022


Copy link

Xuantung89 commented Sep 25, 2022

Verify Github on Galxe. gid:hqaGx3KAt8heyLH9WYEKkm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment