网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

如何在linux中使用CSF防火墙对恶意请求进行屏蔽-创新互联

本篇文章为大家展示了如何在linux中使用CSF防火墙对恶意请求进行屏蔽,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。

成都创新互联公司是一家专业提供灯塔企业网站建设,专注与做网站、成都网站制作H5高端网站建设、小程序制作等业务。10年已为灯塔众多企业、政府机构等服务。创新互联专业网站设计公司优惠进行中。

关于ddos的防护

根据readme.txt的描述,进行ddos防护的功能主要是靠/etc/csf/csf.conf中的配置进行控制的,尤其是当中的PORTFLOOD参数,一般都进行如下设置:

#Syntax for the PORTFLOOD setting:
#PORTFLOOD is a comma separated list of:
port;protocol;hit count*;interval seconds
#So, a setting of PORTFLOOD = "22;tcp;5;300,80;tcp;20;5" means:
#1. If more than 5 connections to tcp port 22 within 300 seconds, then block
#that IP address from port 22 for at least 300 seconds after the last packet is
#seen, i.e. there must be a "quiet" period of 300 seconds before the block is
#lifted
#2. If more than 20 connections to tcp port 80 within 5 seconds, then block
#that IP address from port 80 for at least 5 seconds after the last packet is
#seen, i.e. there must be a "quiet" period of 5 seconds before the block is
#lifted

这个可以根据个人需要修改。

关于black list

blacklist 就在/etc/csf/csf.deny里,可以有多种书写方式,在该文件的顶部描述的十分清楚:

###############################################################################
# Copyright 2006-2017, Way to the Web Limited
# URL: http://www.configserver.com
# Email: sales@waytotheweb.com
###############################################################################
# The following IP addresses will be blocked in iptables
# One IP address per line
# CIDR addressing allowed with a quaded IP (e.g. 192.168.254.0/24)
# Only list IP addresses, not domain names (they will be ignored)
#
# Note: If you add the text "do not delete" to the comments of an entry then
# DENY_IP_LIMIT will ignore those entries and not remove them
#
# Advanced port+ip filtering allowed with the following format
# tcp/udp|in/out|s/d=port|s/d=ip
#
# See readme.txt for more information regarding advanced port filtering
#

简要概括就是每一行代表一个ip,也可以代表一个ip段(CIDR),而且我们也可以加注释,甚至可以指定端口和协议。
最后,在做出修改后想要生效记得用csf -r命令。

针对恶意代理请求的防护方案

当然,我用这个的目的是为了根本解决之前的恶意代理占用带宽的问题。有了这个工具,就可以十分轻松的进行控制了,思路如下:

  1. 首先,搜索Apache的log(/var/log/apache2/access.log),查找所有应被屏蔽的log条目(我这里指的是所有被403的请求)。

  2. 然后,提取每条Log记录对应的ip地址。

  3. 对结果进行排序去重,生成black list。

  4. blacklist 写入csf.deny

  5. 重启csf防护服务。

实现起来超级简单:

复制代码 代码如下:


root@server:~# cat /var/log/apache2/access.log |grep \ 403\ |awk '{print $1}'|sort|uniq >> /etc/csf/csf.deny

可以手动查看下结果是否正确,确认之后既可以csf -r重启服务了。

上述内容就是如何在linux中使用CSF防火墙对恶意请求进行屏蔽,你们学到知识或技能了吗?如果还想学到更多技能或者丰富自己的知识储备,欢迎关注创新互联行业资讯频道。


分享文章:如何在linux中使用CSF防火墙对恶意请求进行屏蔽-创新互联
网页地址:http://bjjierui.cn/article/ccgedp.html

其他资讯