Anti-DDoS Protection Script

Principle:

Use a Cron scheduled task to run a script at regular intervals to count the maximum number of connections for a single IP. If it exceeds the threshold, APF or iptables is used to block it, and it is released after the preset block time.

Installation:

wget http://www.inetbase.com/scripts/ddos/install.sh
chmod +x install.sh
./install.sh

Uninstallation:

wget http://www.inetbase.com/scripts/ddos/uninstall.sh
chmod +x uninstall.sh
./uninstall.sh

Configuration:

/usr/local/ddos/ddos.conf

##### Paths of the script and other files
PROGDIR="/usr/local/ddos"
PROG="/usr/local/ddos/ddos.sh"
IGNORE_IP_LIST="/usr/local/ddos/ignore.ip.list"
CRON="/etc/cron.d/ddos.cron"
APF="/etc/apf/apf"
IPT="/sbin/iptables"

##### frequency in minutes for running the script
##### Caution: Every time this setting is changed, run the script with --cron how many minutes between each execution for statistics
#####          option so that the new frequency takes effect
FREQ=1

##### How many connections define a bad IP? Indicate that below. Block an IP when it reaches how many maximum connections
NO_OF_CONNECTIONS=150

##### APF_BAN=1 (Make sure your APF version is at least 0.96, confirm that APF is installed and the version is greater than 0.96)
##### APF_BAN=0 (Uses iptables for banning ips instead of APF, use iptables in place of APF)
APF_BAN=1

##### KILL=0 (Bad IPs aren't banned, good for interactive execution of script)
##### KILL=1 (Recommended setting, recommended)
KILL=1

##### An email is sent to the following address when an IP is banned. Who should be notified after an IP is blocked
##### Blank would suppress sending of mails
EMAIL_TO="root"

##### Number of seconds the banned

Leave a Comment

Your email address will not be published. Required fields are marked *

中文 EN
🚀

RedGate VPN

免费节点太挤太慢?
升级高速稳定专线

立即体验 →

告别卡顿

RedGate VPN
全球高速节点

免费下载 →
Scroll to Top