标签:黑客攻击 version previous 服务器 防火墙 ddos
linux服务器运营过程中可能会受到黑客攻击,常见的攻击方式有SYN,DDOS等。通过更换IP,查找被攻击的站点可能避开攻击,但是中断服务的时间比较长。比较彻底的解决方法是添置硬件防火墙。不过,硬件防火墙价格比较昂贵。在没有硬防的情况下,寻找软件代替是最直接的方法,比如用iptables,但 是iptables不能自动屏蔽,只能手动屏蔽。这里要介绍的就是一款能够自动屏蔽DDOS攻击者IP的软件:DDoS Deflate。
过滤出访问网页次数最多的IP:
DDOS deflate是一个轻量级的脚本,以协助阻止拒绝服务攻击的过程中的bash shell脚本。
安装:
# wget http://www.inetbase.com/scripts/ddos/install.sh # chmod 0700 install.sh# cat install.sh#!/bin/shif [ -d ‘/usr/local/ddos‘ ]; then echo; echo; echo "Please un-install the previous version first" exit 0else mkdir /usr/local/ddosficlear echo; echo ‘Installing DOS-Deflate 0.6‘; echo echo; echo -n ‘Downloading source files...‘wget -q -O /usr/local/ddos/ddos.conf http://www.inetbase.com/scripts/ddos/ddos.confecho -n ‘.‘wget -q -O /usr/local/ddos/LICENSE http://www.inetbase.com/scripts/ddos/LICENSEecho -n ‘.‘wget -q -O /usr/local/ddos/ignore.ip.list http://www.inetbase.com/scripts/ddos/ignore.ip.listecho -n ‘.‘wget -q -O /usr/local/ddos/ddos.sh http://www.inetbase.com/scripts/ddos/ddos.shchmod 0755 /usr/local/ddos/ddos.sh cp -s /usr/local/ddos/ddos.sh /usr/local/sbin/ddos echo ‘...done‘echo; echo -n ‘Creating cron to run script every minute.....(Default setting)‘/usr/local/ddos/ddos.sh --cron > /dev/null 2>&1echo ‘.....done‘echo; echo ‘Installation has completed.‘echo ‘Config file is at /usr/local/ddos/ddos.conf‘echo ‘Please send in your comments and/or suggestions to zaf@vsnl.com‘echo cat /usr/local/ddos/LICENSE | less# ./install.sh
配置文件:
# ll /usr/local/ddos/总用量 24-rw-r--r--. 1 root root 971 1月 10 2006 ddos.conf-rwxr-xr-x. 1 root root 3945 1月 10 2006 ddos.sh-rw-r--r--. 1 root root 10 1月 10 2006 ignore.ip.list-rw-r--r--. 1 root root 10113 1月 10 2006 LICENSE# cat /usr/local/ddos/ddos.conf##### Paths of the script and other filesPROGDIR="/usr/local/ddos" #文件存放目录PROG="/usr/local/ddos/ddos.sh" #主要功能脚本IGNORE_IP_LIST="/usr/local/ddos/ignore.ip.list" #白名单地址列表CRON="/etc/cron.d/ddos.cron" #crond定时任务脚本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##### option so that the new frequency takes effectFREQ=1 #ddos.sh执行的频率,单位是分钟,搭配crontab来执行.##### How many connections define a bad IP? Indicate that below.NO_OF_CONNECTIONS=150 #最大连接数设置,超过这个数字的IP就会屏蔽##### APF_BAN=1 (Make sure your APF version is atleast 0.96)##### APF_BAN=0 (Uses iptables for banning ips instead of APF)APF_BAN=1 #1:使用APF 0:使用iptables,一般情况下你是使用iptables来做防火墙,所以这里你需要将APF_BAN的值改为0##### KILL=0 (Bad IPs are‘nt banned, good for interactive execution of script)##### KILL=1 (Recommended setting)KILL=1 #将非法的的IP加入iptables的INPUT链中,DROP之.##### An email is sent to the following address when an IP is banned.##### Blank would suppress sending of mailsEMAIL_TO="root" #发送电子邮件报警的邮箱地址##### Number of seconds the banned ip should remain in blacklist.BAN_PERIOD=600 #屏蔽IP的时间,根据情况调整
修改以上文件19行:
任务执行计划:
本文出自 “zpp” 博客,谢绝转载!
标签:黑客攻击 version previous 服务器 防火墙 ddos
原文地址:http://1439337369.blog.51cto.com/10270624/1826635