Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
daily cron script to ban (for a longer time) sites repeatedly banned by fail2ban
# 詳見: 「fail2ban: 新手老手 root 網管都要練的金鐘罩」
sed -i.bak '/repeated-fail2ban/,+1d' /etc/hosts.deny
/etc/fail2ban/ -d 7 -g 3 -i 10 >> /etc/hosts.deny
cat <<EOF > /etc/apache2/conf.d/repeated-fail2ban
<Location />
Order Allow,Deny
Allow from all
/etc/fail2ban/ -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