Administrator
发布于 2025-05-10 / 3 阅读
0
0

coredns使用教程

coreDNS教程

官网下载并解压到 /usr/local/bin,

:根据实际情况修改以下内容

注册为service

[Unit]
Description=CoreDNS

[Service]
Type=notify
ExecStart=coredns -conf /data/coredns/Corefile

编写Corefile

例如

.:53 {
    errors
    health
    ready
    kubernetes cluster.local in-addr.arpa ip6.arpa {
        pods insecure
        upstream /etc/resolv.conf
        fallthrough in-addr.arpa ip6.arpa
    }
    prometheus :9153
    forward . /etc/resolv.conf
    cache 30
    loop
    reload
    loadbalance
}
import "/data/coredns/zones/*"

编写分片文件

例如

hosts类型:

my-app.com {
    hosts {
       xx.xx.xx.xx my-app.com
     }
 }      

CName类型:

$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

评论