准备
[root@VM_100_6_centos opt]# ls
coredns_1.6.5_linux_amd64.tgz rh
[root@VM_100_6_centos opt]#
[root@VM_100_6_centos opt]#
[root@VM_100_6_centos opt]# tar xzvf coredns_1.6.5_linux_amd64.tgz
coredns
[root@VM_100_6_centos opt]# ls
coredns coredns_1.6.5_linux_amd64.tgz rh
[root@VM_100_6_centos opt]# file coredns
coredns: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, stripped
查看帮助
[root@VM_100_6_centos opt]# ./coredns --help
Usage of ./coredns:
-conf string
Corefile to load (default "Corefile")
-dns.port string
Default port (default "53")
-pidfile string
Path to write pid file
-plugins
List installed plugins
-quiet
Quiet mode (no initialization output)
-version
Show version
创建两个配置文件 Corefile 和 example.org
[root@VM_100_6_centos opt]# ll
total 53108
-rwxr-xr-x 1 33 33 41365504 Nov 5 21:57 coredns
-rw-r--r-- 1 root root 13002512 Nov 21 16:59 coredns_1.6.5_linux_amd64.tgz
-rw-r--r-- 1 root root 145 Nov 21 17:09 Corefile
-rw-r--r-- 1 root root 434 Nov 21 17:08 example.org
drwxr-xr-x. 2 root root 4096 Mar 26 2015 rh
[root@VM_100_6_centos opt]#
[root@VM_100_6_centos opt]# cat Corefile
example.org {
file example.org
prometheus # enable metrics
errors # show errors
log # enable query logs
}
[root@VM_100_6_centos opt]# cat example.org
$ORIGIN example.org.
@ 3600 IN SOA sns.dns.icann.org. noc.dns.icann.org. (
2017042745 ; serial
7200 ; refresh (2 hours)
3600 ; retry (1 hour)
1209600 ; expire (2 weeks)
3600 ; minimum (1 hour)
)
3600 IN NS a.iana-servers.net.
3600 IN NS b.iana-servers.net.
www IN A 127.0.0.1
IN AAAA ::1
[root@VM_100_6_centos opt]#
启动CoreDNS运行
[root@VM_100_6_centos opt]# ./coredns -conf Corefile -dns.port 1053
example.org.:1053
CoreDNS-1.6.5
linux/amd64, go1.13.4, c2fd1b2
使用dig测试
[root@VM_100_6_centos ~]# dig -p 1053 @localhost AAAA www.example.org +noall +answer
; <<>> DiG 9.9.4-RedHat-9.9.4-50.el7 <<>> -p 1053 @localhost AAAA www.example.org +noall +answer
; (2 servers found)
;; global options: +cmd
www.example.org. 3600 IN AAAA ::1
[root@VM_100_6_centos ~]#
在CoreDNS的标准输出显示
[INFO] [::1]:44111 - 32024 "AAAA IN www.example.org. udp 44 false 4096" NOERROR qr,aa,rd 162 0.00012048s
DEMO 跑成功了
下面研究 :
zone file 的配置 (同bind9)
CoreDNS集群/主备
CoreDNS插件
CoreDNS已经安装的插件
[root@VM_100_6_centos opt]# ./coredns -plugins
Server types:
dns
Caddyfile loaders:
flag
default
Other plugins:
dns.acl
dns.any
dns.auto
dns.autopath
dns.azure
dns.bind
dns.cache
dns.cancel
dns.chaos
dns.clouddns
dns.debug
dns.dnssec
dns.dnstap
dns.erratic
dns.errors
dns.etcd
dns.federation
dns.file
dns.forward
dns.grpc
dns.health
dns.hosts
dns.k8s_external
dns.kubernetes
dns.loadbalance
dns.log
dns.loop
dns.metadata
dns.nsid
dns.pprof
dns.prometheus
dns.ready
dns.reload
dns.rewrite
dns.root
dns.route53
dns.secondary
dns.sign
dns.template
dns.tls
dns.trace
dns.transfer
dns.whoami
on