This script is working on all Linux standard distribution, but use at your own risk! The script has been made to automated the creation of iptables rules. There is an easy to use menu as well
root:~# ./firewall.sh
Firewall script by www.waltercedric.com
Credits to all various authors - GNU/GPL 3.0 Script
Choose one of the following options:
[N]ew firewall rules
[C]lear all firewall rules
[T]est firewall rules
[S]ave firewall rules to /etc/network/iptables
[E]xit
########## SSH #################################################
SSH_PORT=22
# This notes every NEW connection to port ${SSH_PORT} and adds it to the recent "list"
# If your IP is on the recent list, and you have ${SSH_LOGIN_ATTEMPT} # or more entries on the list in the
# last ${SSH_LOGIN_ATTEMPT_TIMEFRAME} seconds, we drop your request.
SSH_LOGIN_ATTEMPT_PROTECTION="true"
SSH_LOGIN_ATTEMPT=4
SSH_LOGIN_ATTEMPT_TIMEFRAME_SECONDS=90
SSH_ALLOW_ONLY_IP="false"
SSH_ALLOW_ONLY_IP_LIST="122.xx.yy.zz/29"
#### FILES #####
BLOCKED_IP_TDB=/root/.fw/blocked.ip.txt
SPOOFIP=""