Skip to content

Instantly share code, notes, and snippets.

@wgroenewold
Last active March 14, 2017 16:08
Show Gist options
  • Save wgroenewold/d380543ca0634081af1b9c678fabcf4b to your computer and use it in GitHub Desktop.
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
#!/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;
@wgroenewold
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment