Last active
July 3, 2017 17:50
-
-
Save tezvi/350ba75532ff2a89f7cb8d4fa5d95b8f to your computer and use it in GitHub Desktop.
Output unique banned IP addresses from fail2ban service log file
This file contains hidden or 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 | |
# output unique ip addresses banned by fail2log | |
grep "Ban " /var/log/fail2ban.log \ | |
| grep `date -d "1 day ago" +%Y-%m-%d` \ | |
| awk '{print $NF " ("$NF") "$6""}' \ | |
| sort \ | |
| uniq -c \ | |
| awk '{print $2" "$3" "$4" "$1}' \ | |
| logresolve \ | |
| awk '{print $4" "$1" "$2" "$3}' \ | |
| sort -rn |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment