创建文件夹
mkdir / coredns/ config/
添加一个CoreDNS配置文件
cat >/coredns/config/Corefile<<EOF.:53 {forward . 114.114.114.114:53log}EOF
启动docker
docker run - d -- name coredns -- restart= always \- v / coredns/ config: / etc/ coredns \- p 53 : 53 / udp \registry. aliyuncs. com/ google_containers/ coredns: v1. 10.1 - conf / etc/ coredns/ Corefile \
hosts 部分添加你需要的域名
vim /coredns/config/Corefile
.:53 {hosts {10.40.92.44 api.xxx.cnfallthrough}forward . 10.40.92.1:53logerrors
}
登录一台服务器测试
#编辑vim /etc/resolv.conf#nameserver 部分添加域名服务的IP地址nameserver 10.40.92.6
正向解析
# nslookup sit-m.dreamingtc.cnServer: 10.40.92.6
Address: 10.40.92.6#53Name: sit-m.xxx.cn
Address: 10.40.92.44
反向解析
#nslookup 10.40.92.4444.92.40.10.in-addr.arpa name = Api.XXX.cn.