Last active
March 23, 2019 19:13
-
-
Save siutin/e32f644375062ab50824148eba54e605 to your computer and use it in GitHub Desktop.
list all banned ip in fail2ban
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
## usage: fail2ban-client-ls-ip [JAIL] | |
JAIL=$1 | |
PROGNAME=$0 | |
if [ -z $JAIL ]; then | |
[ -z $PROGNAME ] && echo "ERROR: $PROGNAME is empty" && exit 1 | |
sudo fail2ban-client status | | |
grep 'Jail list:' | | |
sed "s/ //g" | | |
awk '{print $2}' | | |
sed "s/,/\n/g" | | |
xargs -L 1 -I{} /bin/bash -c 'echo -e "\njail: {}"; $0 {};' $PROGNAME | |
else | |
sudo fail2ban-client status $JAIL | grep -oE '((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)' | sort | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment