本篇文章為大家展示了如何在linux中使用CSF防火墻對惡意請求進(jìn)行屏蔽,內(nèi)容簡明扼要并且容易理解,絕對能使你眼前一亮,通過這篇文章的詳細(xì)介紹希望你能有所收獲。
關(guān)于ddos的防護(hù)
根據(jù)readme.txt的描述,進(jìn)行ddos防護(hù)的功能主要是靠/etc/csf/csf.conf中的配置進(jìn)行控制的,尤其是當(dāng)中的PORTFLOOD參數(shù),一般都進(jìn)行如下設(shè)置:
#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
這個可以根據(jù)個人需要修改。
關(guān)于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),而且我們也可以加注釋,甚至可以指定端口和協(xié)議。
最后,在做出修改后想要生效記得用csf -r
命令。
針對惡意代理請求的防護(hù)方案
當(dāng)然,我用這個的目的是為了根本解決之前的惡意代理占用帶寬的問題。有了這個工具,就可以十分輕松的進(jìn)行控制了,思路如下:
首先,搜索Apache的log(/var/log/apache2/access.log),查找所有應(yīng)被屏蔽的log條目(我這里指的是所有被403的請求)。
然后,提取每條Log記錄對應(yīng)的ip地址。
對結(jié)果進(jìn)行排序去重,生成black list。
blacklist 寫入csf.deny
重啟csf防護(hù)服務(wù)。
實現(xiàn)起來超級簡單:
復(fù)制代碼 代碼如下:
root@server:~# cat /var/log/apache2/access.log |grep \ 403\ |awk '{print $1}'|sort|uniq >> /etc/csf/csf.deny
可以手動查看下結(jié)果是否正確,確認(rèn)之后既可以csf -r
重啟服務(wù)了。
上述內(nèi)容就是如何在linux中使用CSF防火墻對惡意請求進(jìn)行屏蔽,你們學(xué)到知識或技能了嗎?如果還想學(xué)到更多技能或者豐富自己的知識儲備,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。
當(dāng)前文章:如何在linux中使用CSF防火墻對惡意請求進(jìn)行屏蔽-創(chuàng)新互聯(lián)
文章來源:http://m.kartarina.com/article18/ccgedp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供微信公眾號、云服務(wù)器、品牌網(wǎng)站建設(shè)、微信小程序、網(wǎng)站改版、做網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容