去评论
dz插件网

Discuz!论坛建站防DDOS攻击脚本[适用于宝塔、AMH linux服务器]

admin
2020/11/26 14:33:14
Discuz!论坛建站防DDOS攻击脚本[适用于宝塔、AMH linux服务器]:

原理:
用Cron计划任务定时执行脚本统计单个IP的最大连接数,如果超过阈值则用APF或者iptables来阻止,并在预设的阻止时间后释放。
安装:
  1. wget https://www.dz-x.net/scripts/install.sh
  2. chmod +x install.sh
  3. ./install.sh

卸载:
  1. wget https://www.dz-x.net/scripts/uninstall.sh
  2. chmod +x uninstall.sh
  3. ./uninstall.sh

配置:
  1. /usr/local/ddos/ddos.conf

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

  8. ##### frequency in minutes for running the script
  9. ##### Caution: Every time this setting is changed, run the script with --cron 多少分钟执行一次统计
  10. #####          option so that the new frequency takes effect
  11. FREQ=1

  12. ##### How many connections define a bad IP? Indicate that below. 当一个IP的最大连接是多少的时候阻止它
  13. NO_OF_CONNECTIONS=150

  14. ##### APF_BAN=1 (Make sure your APF version is atleast 0.96,确定安装APF并且版本大雨0.96)
  15. ##### APF_BAN=0 (Uses iptables for banning ips instead of APF,用iptables代理APF)
  16. APF_BAN=1

  17. ##### KILL=0 (Bad IPs are'nt banned, good for interactive execution of script)
  18. ##### KILL=1 (Recommended setting,推荐设置)
  19. KILL=1

  20. ##### An email is sent to the following address when an IP is banned.阻止一个IP后通知谁
  21. ##### Blank would suppress sending of mails
  22. EMAIL_TO="root"

  23. ##### Number of seconds the banned