内网中物理机、虚拟机等设备较多,配置
hosts 文件太麻烦,因此想到利用一台设备搭建 DNS 服务器。
关键词:DNS
拉取镜像
1
| docker pull coredns/coredns
|
创建配置文件
1 2 3 4 5 6 7 8 9
| # /etc/coredns/Corefile .:53 { hosts { 10.0.0.1 xiexianbin.cn fallthrough } forward . 8.8.8.8:53 9.9.9.9 log }
|
1 2 3 4 5 6 7 8 9 10
| # /etc/coredns/Corefile .:53 { hosts /etc/coredns/hosts { fallthrough } forward . 8.8.8.8:53 9.9.9.9 log } # cat hosts 10.0.0.1 xiexianbin.cn
|
- 将所有
lo 域名根据同一目录下的 hosts 文件解析
- 所有其他的域名转发到 DNS 服务器 202.96.128.86:53
1 2 3 4 5 6 7 8 9 10
| # /Corefile lo:53 { hosts /etc/coredns/hosts log }
.:53 { forward . 202.96.128.86:53 log }
|
部署yaml
1 2 3 4 5 6 7 8 9
| version: '3.3' services: coreDNS: image: coredns/coredns container_name: coredns volumes: - ./Corefile:/Corefile ports: - 53:53/udp
|