# 插件/循环：检测到区域 "." 的循环（127.0.0.1:53），请参阅 https://coredns.io/plugins/loop#troubleshooting

- **ID:** `kubernetes/coredns-loop-detected`
- **领域:** kubernetes
- **类别:** network_error
- **错误码:** `K8S-DNS-003`
- **验证级别:** ai_generated
- **修复率:** 85%

## 根因

CoreDNS 将 DNS 查询转发给自己，造成循环，通常是因为节点的 /etc/resolv.conf 指向 localhost 或 Pod 的 DNS 策略配置了错误的上游。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| coredns 1.8.0 | active | — | — |
| coredns 1.9.0 | active | — | — |
| coredns 1.10.0 | active | — | — |
| kubernetes 1.22 | active | — | — |
| kubernetes 1.24 | active | — | — |

## 解决方案

1. ```
   编辑 CoreDNS ConfigMap（kube-system/coredns）以添加 `loop` 插件并设置正确的上游 DNS。例如，确保 forward 指令指向有效的外部 DNS（例如 `forward . /etc/resolv.conf`），而不是 localhost。
   ```
2. ```
   检查节点的 /etc/resolv.conf 中是否有指向 127.0.0.1 或回环地址的 nameserver 条目。如果有，将其更改为有效的 DNS 服务器 IP（例如 8.8.8.8）并重启 kubelet。
   ```

## 无效尝试

- **Delete the CoreDNS pod and let it restart.** — The loop is caused by configuration, not a transient state; restarting will not fix the underlying issue. (95% 失败率)
- **Set the node's /etc/resolv.conf to use a public DNS like 8.8.8.8.** — This may break cluster-internal DNS resolution for services and pods. (60% 失败率)
