Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
daily cron script to ban (for a longer time) sites repeatedly banned by fail2ban
#!/bin/sh
# 詳見: 「fail2ban: 新手老手 root 網管都要練的金鐘罩」
# http://newtoypia.blogspot.tw/2016/04/fail2ban.html
sed -i.bak '/repeated-fail2ban/,+1d' /etc/hosts.deny
/etc/fail2ban/repeated-fail2ban.pl -d 7 -g 3 -i 10 >> /etc/hosts.deny
cat <<EOF > /etc/apache2/conf.d/repeated-fail2ban
<Location />
Order Allow,Deny
Allow from all
EOF
/etc/fail2ban/repeated-fail2ban.pl -f apache2 -d 7 -g 3 -i 10 | sed 's/^/\t/' >> /etc/apache2/conf.d/repeated-fail2ban
echo "</Location>" >> /etc/apache2/conf.d/repeated-fail2ban
service apache2 restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.