1.虚拟机安装(略)
2.centos搭建(略)
3.centos7安装宝塔+部署docker(略)
4.拉取 CoreDNS的Docker镜像
sudo docker pull coredns/coredns
- 首先,创建一个名为Corefile的文件,用于配置CoreDNS的行为,可以使用
vi
或者nano
命令:
sudo vi Corefile
- 在Corefile中添加以下内容代表运行一个监听在53端口的DNS服务器:
. {
forward . 8.8.8.8:53
log
errors
}
-
然后保存并退出编辑器。
-
现在你可以启动CoreDNS了:
sudo docker run -d --name=coredns -v $(pwd)/Corefile:/Corefile -p 53:53/udp coredns/coredns -conf /Corefile
这行命令的含义是:在后台模式运行一个名为coredns的容器,将当前路径下的Corefile映射到容器的/Corefile,将容器的53端口映射到主机的53端口,并将conf配置文件指向/Corefile。
3.更改配置重新启动coredns(防火墙不可关闭)
sudo docker stop coredns
sudo docker rm coredns
sudo docker run -d --name=coredns -v $(pwd)/Corefile:/Corefile -p 53:53/udp coredns/coredns -conf /Corefile