# IP地址封锁

[IP地址](https://www.edgepedia.org/zh/ip-address)封锁是一种网络与应用安全控制措施，它拒绝来自或发往特定IP地址、地址段或地址列表的流量，方式可以是在网络层丢弃数据包，也可以是在应用层拒绝请求。它用于阻断已知的恶意来源、限制对内部系统的访问，以及减少滥用性流量，例如网页抓取、暴力破解登录尝试和分布式拒绝服务（DDoS）攻击。

| 关键事实 | 详情 |
|---|---|
| 所处位置 | Web应用防火墙中的IP访问规则先于自定义规则运行；被封锁的请求会阻止后续自定义规则对其进行评估<sup>[1](https://developers.cloudflare.com/waf/concepts/)</sup> |
| 主要弱点 | 当攻击分散到大量源IP上时，源IP字段不再是有力的指标，也不会被选为攻击特征的一部分<sup>[2](https://developers.cloudflare.com/ddos-protection/about/how-ddos-protection-works/)</sup> |
| 补充性控制 | 速率限制规则可以按会话Cookie而非按IP来计数请求，从而将来自不同地址但属于同一会话的请求归为一组，这是僵尸网络的典型模式<sup>[3](https://developers.cloudflare.com/waf/rate-limiting-rules/best-practices/)</sup> |
| 标准背景 | RFC 7754记录了互联网服务封锁与过滤的技术考量，并指出在使用HTTPS时，过滤系统必须基于网络层和传输层信息进行封锁<sup>[4](https://www.rfc-editor.org/info/rfc7754/)</sup> |
| 有效性证据 | 一项关于IP黑名单有效性的大规模网络监测研究已经发表，用以评估黑名单在实践中的表现<sup>[5](https://arxiv.org/abs/2308.08356)</sup> |
| 顺序很重要 | 在网络防火墙中，ICMP封锁规则之前应当有一条允许来自提供商公网IP的ICMP的规则<sup>[6](https://9cfb61eb.previews.developers.cloudflare.com/cloudflare-network-firewall/about/ruleset-logic/)</sup> |

## 工作原理

按IP地址封锁可以在多个层面进行。有状态包过滤器会将数据包的源IP地址和目的IP地址与其规则进行比对，然后要么允许数据包进入网络，要么将其封锁<sup>[7](https://www.rfc-editor.org/rfc/pdfrfc/rfc4487.txt.pdf)</sup>。在应用层，Web应用防火墙（WAF）检查传入的Web和API请求，并基于称为规则集的规则集合过滤不受欢迎的流量；封锁请求的IP访问规则会在自定义规则运行之前生效<sup>[1](https://developers.cloudflare.com/waf/concepts/)</sup>。WAF策略还可以执行正向和负向安全模型，控制来自特定位置和IP地址的传入流量<sup>[8](https://www.cloudflare.com/learning/ddos/how-to-prevent-ddos-attacks/)</sup>。

**规则顺序与例外。** 实际部署依赖于明确的顺序。同样，在封锁ICMP流量时，网络防火墙的规则应首先允许来自保护提供商公网IP、发往受保护端点IP的ICMP，然后再应用封锁规则<sup>[6](https://9cfb61eb.previews.developers.cloudflare.com/cloudflare-network-firewall/about/ruleset-logic/)</sup>。

## 用途

**DDoS缓解。** IP封锁是拒绝服务防御的若干工具之一。Cloudflare的DDoS防护在[OSI模型](https://www.edgepedia.org/zh/osi-model)的第3层、第4层和第7层保护Web和网络基础设施，其高级TCP防护会在异常TCP/IP行为到达应用服务器之前识别并将其丢弃<sup>[9](https://developers.cloudflare.com/ddos-protection/frequently-asked-questions/)</sup>。然而，按源地址封锁只有在攻击者来自有限的一组地址时才有效。当攻击是分布式的，即源自许多源IP时，源IP字段不能作为有力的指标，自动化缓解转而从其他字段构建攻击特征<sup>[2](https://developers.cloudflare.com/ddos-protection/about/how-ddos-protection-works/)</sup>。诸如主动互联网流量过滤之类的研究提案通过使不受欢迎的流量尽可能在其源头附近被封锁来解决这一问题，因为公共访问站点无法事先封锁未经授权的流量<sup>[10](https://arxiv.org/abs/cs/0403042)</sup>。

**速率限制与滥用控制。** 由于坚决的攻击者会轮换地址，IP封锁通常与速率限制配合使用，后者限制客户端在给定时间窗口内可以发起的请求数量，例如保护登录端点免受暴力破解攻击<sup>[11](https://7617740f.previews.developers.cloudflare.com/waf/rate-limiting-rules/)</sup>。以会话Cookie为键的速率限制会将来自不同IP地址但属于同一会话的请求归为一组，这是僵尸网络执行分布式攻击时的常见情形<sup>[3](https://developers.cloudflare.com/waf/rate-limiting-rules/best-practices/)</sup>。

**黑名单。** 已知恶意地址的封锁列表是一种广泛使用的IP封锁形式。其实际表现已在一项关于黑名单有效性的大规模网络监测研究中得到考察<sup>[5](https://arxiv.org/abs/2308.08356)</sup>。商业DDoS服务将黑名单检查纳入其流量过滤；一种被描述的访客筛查流程包括站点信誉、访客的IP是否已被列入黑名单，以及HTTP头部是否显得可疑<sup>[12](https://www.techradar.com/news/best-ddos-protection)</sup>。

## 局限性

核心局限在于，IP地址标识的是网络位置，而不是个人或客户端。分布式攻击分散到许多地址，正是为了击败基于源的规则<sup>[2](https://developers.cloudflare.com/ddos-protection/about/how-ddos-protection-works/)</sup>。加密也限制了封锁者所能看到的内容；RFC 7754指出，在使用HTTPS时，过滤系统必须基于网络层和传输层信息而非内容进行封锁<sup>[4](https://www.rfc-editor.org/info/rfc7754/)</sup>。

运营实践反映了这些局限。

## 相关控制措施

IP封锁处于分层防御之中。WAF在Web应用与互联网之间建立一道屏障，并按规则集过滤请求<sup>[1](https://developers.cloudflare.com/waf/concepts/)</sup>。DDoS防护系统持续运行；Cloudflare的`dosd`系统在其网络的每个数据中心的每台服务器上运行，并与客户的Web服务器同步，以识别其健康状况并触发缓解动作<sup>[13](https://d1-custom-bindings-docs.previews.developers.cloudflare.com/ddos-protection/about/components/)</sup>。使用网络层托管规则在边缘检测和缓解第3/4层DDoS攻击平均最多需要三秒<sup>[2](https://developers.cloudflare.com/ddos-protection/about/how-ddos-protection-works/)</sup>。在IP封锁过于粗糙的情况下，托管质询动作（例如[JavaScript](https://www.edgepedia.org/zh/javascript)质询）可以区分浏览器与简单脚本，而不会永久排除某个地址<sup>[12](https://www.techradar.com/news/best-ddos-protection)</sup>。

## References

1. [Concepts, Cloudflare Web Application Firewall (WAF) docs](https://developers.cloudflare.com/waf/concepts/)
2. [How DDoS protection works, Cloudflare DDoS Protection docs](https://developers.cloudflare.com/ddos-protection/about/how-ddos-protection-works/)
3. [Rate limiting best practices, Cloudflare WAF docs](https://developers.cloudflare.com/waf/rate-limiting-rules/best-practices/)
4. [RFC 7754: Technical Considerations for Internet Service Blocking and Filtering, RFC Editor](https://www.rfc-editor.org/info/rfc7754/)
5. [Evaluating IP Blacklists Effectiveness, arXiv:2308.08356](https://arxiv.org/abs/2308.08356)
6. [Cloudflare Network Firewall ruleset logic](https://9cfb61eb.previews.developers.cloudflare.com/cloudflare-network-firewall/about/ruleset-logic/)
7. [RFC 4487, RFC Editor](https://www.rfc-editor.org/rfc/pdfrfc/rfc4487.txt.pdf)
8. [How to prevent DDoS attacks: Methods and tools, Cloudflare Learning Center](https://www.cloudflare.com/learning/ddos/how-to-prevent-ddos-attacks/)
9. [Frequently asked questions for DDoS Protection, Cloudflare docs](https://developers.cloudflare.com/ddos-protection/frequently-asked-questions/)
10. [Protecting Public-Access Sites Against Distributed Denial-of-Service Attacks, arXiv:cs/0403042](https://arxiv.org/abs/cs/0403042)
11. [Rate limiting rules, Cloudflare WAF docs](https://7617740f.previews.developers.cloudflare.com/waf/rate-limiting-rules/)
12. [Best DDoS protection of 2025, TechRadar](https://www.techradar.com/news/best-ddos-protection)
13. [Main components, Cloudflare DDoS Protection docs](https://d1-custom-bindings-docs.previews.developers.cloudflare.com/ddos-protection/about/components/)

---
*Initially written Sep 17, 2026 · Reviewed: Sep 17, 2026; Oct 15, 2026 · Edited: Oct 15, 2026 · Last review: Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 网络与安全 › Network defense and threats › Firewalls and perimeter defense

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/ip-address-blocking

English original: https://www.edgepedia.org/ip-address-blocking
