惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Secure Thoughts
Security Latest
Security Latest
Simon Willison's Weblog
Simon Willison's Weblog
O
OpenAI News
GbyAI
GbyAI
L
LINUX DO - 最新话题
A
Arctic Wolf
T
Tor Project blog
G
GRAHAM CLULEY
I
InfoQ
博客园_首页
IT之家
IT之家
The Register - Security
The Register - Security
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Proofpoint News Feed
The GitHub Blog
The GitHub Blog
Blog — PlanetScale
Blog — PlanetScale
N
Netflix TechBlog - Medium
K
Kaspersky official blog
博客园 - 三生石上(FineUI控件)
S
SegmentFault 最新的问题
U
Unit 42
PCI Perspectives
PCI Perspectives
量子位
P
Palo Alto Networks Blog
S
Securelist
T
Troy Hunt's Blog
博客园 - 【当耐特】
Recorded Future
Recorded Future
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
S
Security Affairs
Engineering at Meta
Engineering at Meta
T
The Blog of Author Tim Ferriss
博客园 - 聂微东
罗磊的独立博客
N
News and Events Feed by Topic
人人都是产品经理
人人都是产品经理
B
Blog RSS Feed
NISL@THU
NISL@THU
C
Cisco Blogs
T
Threatpost
有赞技术团队
有赞技术团队
Forbes - Security
Forbes - Security
Hugging Face - Blog
Hugging Face - Blog
Last Week in AI
Last Week in AI
T
The Exploit Database - CXSecurity.com
Cloudbric
Cloudbric
Cyberwarzone
Cyberwarzone
Google DeepMind News
Google DeepMind News
C
Cyber Attacks, Cyber Crime and Cyber Security

Rat's Blog - Linux

使用Instantbox快速搭建一个开箱即用的Web端临时Linux系统 - Rat's Blog Windows VPS一键重装为Linux系统 - Rat's Blog Linux VPS一键安装桌面环境和RDP远程桌面连接 - Rat's Blog Debian/Ubuntu使用update-rc.d命令添加/禁止开机启动项 - Rat's Blog Linux VPS纯净版CentOS系统一键安装脚本 - Rat's Blog thefuck:Linux中一款可以自动纠正前一个命令行错误的工具 - Rat's Blog NodeQuery:一款好看的Linux VPS服务器信息监控工具 - Rat's Blog DomainMegaBot:Linux上最好用的批量扫描域名的工具 - Rat's Blog Debian安装PHP 7.2教程 - Rat's Blog
Linux VPS利用iptables string模块屏蔽指定的网站、文件等 - Rat's Blog
博主: Rat's · 2018-02-28 · via Rat's Blog - Linux

说明:在逗比那里看到的一个方法,可以阻止服务器访问某个网站,或文件等,对于爬梯子的,如果有共享行为,可以屏蔽下油管,这个大流量的很容易被Q

原理:一般iptables自带的都有string模块,这个模块的作用就是匹配字符串,匹配到泛域名的URL,然后就把数据包丢弃,就实现了屏蔽泛域名的功能。

方法

以下规则是屏蔽以xx.com为主的所有一级、二级、三级等域名。

#添加屏蔽规则
iptables -A OUTPUT -m string --string "xx.com" --algo bm --to 65535 -j DROP

#删除屏蔽规则,上面添加的代码是什么样,那么删除的代码就是把-I改成-D 
iptables -D OUTPUT -m string --string "xx.com" --algo bm --to 65535 -j DROP

命令详解:

-A
#添加iptables规则;
-D
#删除iptables规则(把添加防火墙规则时代码中的-A改成-D即可删除添加的规则);
-m string
#指定模块;
--string "xx.com"
#指定要匹配的字符串(域名、关键词等);
--algo bm
#指定匹配字符串模式/算法(还有一种更复杂的算法:kmp);
--to 65535
#指定端口,这里代表所有端口(1-65535);
-j DROP
#指匹配到数据包后处理方式,这里是丢弃数据包。

这个模块的作用就是匹配字符串,这个字符串可以是URL、普通文本、文件后缀(后两者时,如果目标网站启用了GZIP类压缩算法,就会无法过滤匹配,毕竟都压缩了)。

比如:.zip,就会把包含.zip的数据库丢弃,这样就会无法下载.zip类型的文件了!

相关教程:iptables封禁BT/PT/SPAM(垃圾邮件)和自定义端口/关键词一键脚本


版权声明:本文为原创文章,版权归 Rat's Blog 所有,转载请注明出处!

本文链接:https://www.moerats.com/archives/524/

如教程需要更新,或者相关链接出现404,可以在文章下面评论留言。