Fail2ban show List of all blocked countries

Hi Foks,

 

I just want to check what countries were the most  blocked once.

So I was locking for some existing function but cannot find any so I wrote it by myself and here is the 1 line code to find out what countries are worst!!!

#!/bin/bash
## all Fail2Ban Log should be logged into /var/log/fail2ban.log then this will work
## you need geoiplookup to get it runningyou can install it with sudo apt install geoip-bin
cat /var/log/fail2ban.log* | grep Ban | sed 's/.*[Bb]an \(.*\)/\1/' | uniq | while read line; do geoiplookup $line; done | sort | uniq -c | sort -nr

 

br

wikrie

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.