type
status
date
slug
summary
tags
category
icon
password
下面给你 最简单、最常用、能直接运行的 Docker DNS 服务器搭建方法。
推荐 CoreDNS —— 轻量、配置简单、Docker 化使用非常方便。
✅ 方案一:用 CoreDNS 搭建 DNS 服务器(最推荐)
1. 创建 CoreDNS 配置文件
在宿主机创建目录:
创建配置文件:
内容写:
意思是:
- 监听 53 端口
- 上游 DNS 用 Google (8.8.8.8) 和 Cloudflare (1.1.1.1)
- 开启缓存 + 日志
2. 用 Docker 运行 CoreDNS
🔍 注意两个端口都要暴露:
- 53/udp(DNS query 主通道)
- 53/tcp(大包、zone 传输等)
3. 测试 DNS 服务是否成功运行
能返回 IP 就成功了。
⭐ 想自定义域名解析?
比如你希望:
a.test.local → 192.168.1.100把 Corefile 改成:
重启:
然后测试:
- Author:Blinky
- URL:http://preview.tangly1024.com/article/2b81c0db-37a0-80b9-9c0e-f98e12f95a12
- Copyright:All articles in this blog, except for special statements, adopt BY-NC-SA agreement. Please indicate the source!










