Posted: Tue Jul 16, 2019 10:00 Post subject: Block IP Script
Hello,
This script checks for failed logins and blocks IP addresses.I need to modify this script to also include local addresses as "192.168." not exclude.
And also add an option for blocking ip address after entering wrong login 3x (three times).
The scripts are stored in the jffs
Code:
#!/bin/sh
############################################################
#
# check_brute_force
# Checks for failed logins and blocks IP addresses
#
############################################################
# Do nothing if there is an existing rule for this IP address
if `iptables -L -n | grep $IP > /dev/null 2>&1`; then
exit 0
fi
case $IP in
"") # Do nothing with empty IP
;;
192.168*) # Exclude local LAN
;;
*) # Add rule against intruding IP
iptables -I INPUT -s $IP -j DROP
RC=$?
;;
esac
exit $RC
# EOF
The second problem is adding firewall rules for SSH login limit.After adding this rule, I can't connect via ssh.