跳至主要内容
五折优惠 全部方案,限时优惠。起价 $2.48/mo
CoreDNS

CoreDNS

CoreDNS 是一款以插件链方式工作的 DNS 服务器。可从文件、etcd 或 Kubernetes 提供区域数据,带缓存转发,并只需在 Corefile 中加一行即可启用 DNS-over-TLS 或 Prometheus 指标。采用 Apache-2.0 许可,GitHub 星标 14,200+。

快速概览

14.3k

GitHub star 数

1

页面浏览量

许可 Apache-2.0 版本 Latest OS Ubuntu Server 24.04 LTS Min RAM 1 GB IP IPV4,IPV6

服务管理

查看 CoreDNS 状态:

systemctl status coredns

重启 CoreDNS:

systemctl restart coredns

重新加载 CoreDNS:

systemctl reload coredns

停止 CoreDNS:

systemctl stop coredns

启动 CoreDNS:

systemctl start coredns

查看 CoreDNS 日志:

journalctl -u coredns -f

DNS 配置

CoreDNS 的主配置为:

/etc/coredns/Corefile

默认配置将 DNS 查询转发至:

1.1.1.1 8.8.8.8

请根据你的具体需求和使用场景配置 Corefile。

修改 Corefile 后重启 CoreDNS:

systemctl restart coredns

DNS 端点

  • DNS: 53/tcp53/udp
  • 健康检查: http://127.0.0.1:8080/health
  • 就绪检查: http://127.0.0.1:8181/ready
  • 指标: http://127.0.0.1:9153/metrics

重要文件与目录

  • 二进制文件: /usr/bin/coredns
  • Corefile: /etc/coredns/Corefile
  • 服务: /etc/systemd/system/coredns.service
  • Sysusers: /usr/lib/sysusers.d/coredns.conf
  • Tmpfiles: /usr/lib/tmpfiles.d/coredns.conf
  • Logrotate: /etc/logrotate.d/coredns
  • 数据目录: /var/lib/coredns
  • 日志文件: /var/log/coredns.log
  • 错误日志: /var/log/coredns.err.log
  • 解析器覆盖设置: /etc/systemd/resolved.conf.d/99-coredns.conf

测试 DNS 解析

直接查询 CoreDNS:

dig @127.0.0.1 example.com

或使用服务器 IP 进行查询:

dig @<SERVER-IP> example.com

The host's /etc/resolv.conf is configured to use:

nameserver 127.0.0.1

注意事项

  • CoreDNS uses systemd-resolved 配置更改以释放 53 端口。
  • The host resolver is pointed to 127.0.0.1.
  • DNS 查询会转发到已配置的上游解析器。
  • CoreDNS runs under the dedicated coredns system user.

立即部署 CoreDNS。 起价 $2.48/月。