| 
                         讲一下我自己的理解: 
    - 配置文件类似于 nginx 配置文件的格式;
 
    - 最外面一级的大括号,对应『服务』的概念。多个服务可以共用一个端口;
 
    - 往里面一级的大括号,对应 plugins 的概念,每一个大括号都是一个 plugin。这里可以看出,plugins 是 CoreDNS  的一等公民;
 
    - 服务之间顺序有无关联没有感觉,但 plugins 之间是严重顺序相关的。某些 plugin 必须用 fallthrough 关键字流向下一个  plugin;
 
    - plugin 内部的配置选项是顺序无关的;
 
    - 从 plugins 页面的介绍看,CoreDNS 的功能还是很强的,既能轻松从 bind 迁移,还能兼容 old-style dns server  的运维习惯;
 
    - 从 CoreDNS 的性能指标看,适合做大型服务。
 
 
当然了,上面的配置文件还可以升级一下,具体我就不解释了: 
- . { 
 -   hosts { 
 -     fallthrough 
 -   } 
 -  
 -   forward . 127.0.0.1:5301 127.0.0.1:5302 { 
 -     max_fails 3 
 -     expire 10s 
 -     health_check 5s 
 -     policy sequential 
 -     except www.baidu.com 
 -   } 
 -  
 -   proxy . 117.50.11.11 117.50.22.22 { 
 -     policy round_robin 
 -   } 
 -  
 -   cache 120 
 -   reload 6s 
 -   log . "{local}:{port} - {>id} '{type} {class} {name} {proto} {size} {>do} {>bufsize}' {rcode} {>rflags} {rsize} {duration}" 
 -   errors 
 - } 
 -  
 - .:5301 { 
 -   forward . tls://8.8.8.8 tls://8.8.4.4 { 
 -     tls_servername dns.google 
 -     force_tcp 
 -     max_fails 3 
 -     expire 10s 
 -     health_check 5s 
 -     policy sequential 
 -   } 
 - } 
 -  
 - .:5302 { 
 -   forward . tls://1.1.1.1 tls://1.0.0.1 { 
 -     tls_servername 1dot1dot1dot1.cloudflare-dns.com 
 -     force_tcp 
 -     max_fails 3 
 -     expire 10s 
 -     health_check 5s 
 -     policy sequential 
 -   } 
 - } 
 
  
定时更新国内域名列表 
编写一个 shell 脚本,用来更新 Corefile 中排除的国内域名列表: 
- $ brew install gnu-sed 
 - $ cat <<EOF > /usr/local/bin/update_coredns.sh 
 - #!/bin/bash 
 -  
 - chinadns=$(curl -sL https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/accelerated-domains.china.conf|awk -F "/" '{print $2}') 
 - touch update_coredns.sed && echo "" > update_coredns.sed 
 - for i in $chinadns; do echo "/except/ s/$/ $i/" >> update_coredns.sed; done 
 - gsed -i "s/(except).*/1/" /usr/local/etc/Corefile 
 - gsed -i -f update_coredns.sed /usr/local/etc/Corefile 
 - EOF 
 - $ sudo chmod +x /usr/local/bin/update_coredns.sh 
 
  
先执行一遍该脚本,更新 Corefile 的配置: 
- $ /usr/local/bin/update_coredns.sh 
 
  
然后通过 Crontab 制作定时任务,每隔两天下午两点更新域名列表: 
- $ crontab -l 
 - 0 14 */2 * * /usr/local/bin/update_coredns.sh 
 
  
开机自启 
                        (编辑:52站长网) 
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! 
                     |