[root@centos7 ~]#vim deny_dos.sh
[root@centos7 ~]#cat deny_dos.sh
#!/bin/bash
#
#*************************************************************
#Author: chen
#QQ: 2088346053
#Date: 2021-12-31
#FileName: deny_dos.sh
#Description: The test script
#Copyright (C): 2021 All rights reserved
#*************************************************************
LINK=100
while true;do
ss -nt | awk -F"[[:space:]]+|:" '/^ESTAB/{print $(NF-2)}'|sort |uniq -
c|while read count ip;do
if [ $count -gt $LINK ];then
iptables -A INPUT -s $ip -j REJECT
fi
done
done
[root@centos7 ~]#chmod +x /root/deny_dos.sh
[root@centos7 ~]#crontab -e
[root@centos7 ~]#crontab -l
*/5 * * * * /root/deny_dos.sh
|