# 错误 1001：DNS 解析错误。源服务器 IP 地址通过 DNS 记录暴露，绕过了 Cloudflare 代理。

- **ID:** `policy/cloudflare-origin-ip-exposed-in-dns`
- **领域:** policy
- **类别:** network_error
- **错误码:** `1001`
- **验证级别:** ai_generated
- **修复率:** 92%

## 根因

域名的 DNS 记录在 Cloudflare 中设置为 '仅 DNS'（灰色云）而不是 '已代理'（橙色云），导致流量绕过 Cloudflare 并暴露源 IP，从而导致潜在的 DDoS 和安全策略违规。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Cloudflare DNS v1 | active | — | — |
| Cloudflare API v4 | active | — | — |

## 解决方案

1. ```
   在 Cloudflare 仪表板中将 DNS 记录从 '仅 DNS' 更改为 '已代理'（橙色云）。
示例：
  # 使用 Cloudflare API：
  curl -X PATCH "https://api.cloudflare.com/client/v4/zones/ZONE_ID/dns_records/RECORD_ID" \
    -H "Authorization: Bearer API_TOKEN" \
    -H "Content-Type: application/json" \
    --data '{"proxied": true}'
   ```
2. ```
   对所有 HTTP/HTTPS 记录使用 Cloudflare 的 '橙色云' 功能，并确保没有 A/AAAA 记录设置为 '仅 DNS'。定期审计所有 DNS 记录。
示例：
  # 列出所有 DNS 记录并检查代理状态
  curl -s "https://api.cloudflare.com/client/v4/zones/ZONE_ID/dns_records" \
    -H "Authorization: Bearer API_TOKEN" | jq '.result[] | select(.proxied == false) | {name, type}'
   ```
3. ```
   使用 Cloudflare 的 '已验证源拉取' 功能，确保只有 Cloudflare IP 可以连接到源，即使 IP 暴露也无妨。
示例：
  # 在 Cloudflare 仪表板中启用：SSL/TLS > 源服务器 > 已验证源拉取 > 开启
  # 然后配置您的 Web 服务器拒绝非 Cloudflare 连接
   ```

## 无效尝试

- **Adding a new proxied A record without removing the old one** — Adding a new A record with the same IP but proxied will not fix the issue if the original unproxied record is still active; both records will resolve, and the unproxied one will expose the IP. (50% 失败率)
- **Changing the origin server IP** — Changing the origin server IP address might temporarily hide the exposed IP, but if the DNS record remains unproxied, the new IP will also be exposed. (70% 失败率)
- **Enabling SSL/TLS settings only** — Enabling 'Always Use HTTPS' or other SSL settings does not prevent DNS-level exposure; the record must be proxied. (80% 失败率)
