Last active
December 15, 2015 18:19
-
-
Save pgib/5302582 to your computer and use it in GitHub Desktop.
Simple script to write a log file suitable for 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/sh | |
if [ $# -lt 1 ]; then | |
echo "Usage: banip <ip>" | |
exit 1 | |
fi | |
for ip in $*; do | |
echo "Banning ip $ip" | |
date=`/bin/date +"%Y-%m-%d %H:%M:%S"` | |
echo "[${date}] ${SUDO_USER} has requested that ${ip} be banned" >> /var/log/manual-ban.log | |
done | |
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
[manual-ban] | |
enabled = true | |
filter = manual-ban | |
action = ipfw | |
logpath = /var/log/manual-ban.log | |
findtime = 2 | |
maxretry = 1 | |
bantime = 86400 |
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
[Definition] | |
# Option: failregex | |
# Notes.: regex to match the password failures messages in the logfile. The | |
# host must be matched by a group named "host". The tag "<HOST>" can | |
# be used for standard IP/hostname matching and is only an alias for | |
# (?:::f{4,6}:)?(?P<host>[\w\-.^_]+) | |
# Values: TEXT | |
# | |
failregex = has requested that (<HOST>) be banned$ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment