Skip to content

Instantly share code, notes, and snippets.

Created July 11, 2011 17:06
Star You must be signed in to star a gist
Save kamermans/1076290 to your computer and use it in GitHub Desktop.
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

biesior commented Sep 23, 2022


Copy link

Verify Github on Galxe. gid:hqaGx3KAt8heyLH9WYEKkm

Copy link

jmsfnch commented Oct 14, 2022

Ta very much!

Copy link


Copy link

CDSoft commented Dec 27, 2023


Since fail2ban banned lists all jails with their banned IP as a list of Python dictionaries, Python can also be used to get the list of jails:

$ fail2ban-client banned
[{'sshd': []}, {'apache-auth': []}, {'apache-badbots': []}, {'apache-noscript': ['AAA.BBB.CCC.DDD', 'AAA.BBB.CCC.DDD']}, {'apache-overflows': []}, {'apache-nohome': []}, {'apache-botsearch': []}, {'apache-fakegooglebot': []}, {'apache-modsecurity': []}, {'apache-shellshock': []}, {'php-url-fopen': []}, {'apache-pass': []}]
$ JAILS=$(python -c "print(' '.join(k for d in $(fail2ban-client banned) for k in d))")
$ echo $JAILS
sshd apache-auth apache-badbots apache-noscript apache-overflows apache-nohome apache-botsearch apache-fakegooglebot apache-modsecurity apache-shellshock php-url-fopen apache-pass

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