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

推荐订阅源

阮一峰的网络日志
阮一峰的网络日志
D
Darknet – Hacking Tools, Hacker News & Cyber Security
S
Schneier on Security
The Last Watchdog
The Last Watchdog
Cyberwarzone
Cyberwarzone
S
Securelist
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
C
Cyber Attacks, Cyber Crime and Cyber Security
L
Lohrmann on Cybersecurity
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 司徒正美
The Cloudflare Blog
V
V2EX
博客园_首页
博客园 - 聂微东
Vercel News
Vercel News
人人都是产品经理
人人都是产品经理
G
GRAHAM CLULEY
T
Tenable Blog
Last Week in AI
Last Week in AI
Y
Y Combinator Blog
L
LINUX DO - 最新话题
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
SecWiki News
SecWiki News
博客园 - 三生石上(FineUI控件)
S
Secure Thoughts
N
News | PayPal Newsroom
T
The Blog of Author Tim Ferriss
The GitHub Blog
The GitHub Blog
T
Troy Hunt's Blog
博客园 - 【当耐特】
Forbes - Security
Forbes - Security
H
Hacker News: Front Page
A
About on SuperTechFans
B
Blog RSS Feed
Engineering at Meta
Engineering at Meta
MongoDB | Blog
MongoDB | Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
罗磊的独立博客
D
DataBreaches.Net
P
Privacy & Cybersecurity Law Blog
Schneier on Security
Schneier on Security
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Google DeepMind News
Google DeepMind News
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Jina AI
Jina AI
D
Docker
P
Proofpoint News Feed

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,可以在文章下面评论留言。