Last active
March 14, 2017 16:08
-
-
Save wgroenewold/d380543ca0634081af1b9c678fabcf4b to your computer and use it in GitHub Desktop.
Auto block IPs - /usr/local/directadmin/scripts/custom/brute_force_notice_ip.sh
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/sh | |
if ! [ -z "$value" ] && [ $value =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]; then | |
found=`iptables -L INPUT -v -n | grep "$value"` | |
if [ "$count" > 100 ] && [ -z "$found" ]; then | |
iptables -I INPUT 10 -s $value -j DROP | |
iptables-save > /etc/iptables.local | |
fi | |
fi | |
exit; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
chmod +x /usr/local/directadmin/scripts/custom/brute_force_notice_ip.sh
chown diradmin:diradmin /usr/local/directadmin/scripts/custom/brute_force_notice_ip.sh
chmod 700 /usr/local/directadmin/scripts/custom/brute_force_notice_ip.sh