目 录CONTENT

文章目录

coredns

xlong
2024-03-25 / 0 评论 / 0 点赞 / 17 阅读 / 3068 字 / 正在检测是否收录...

coredns

配置文件

[root@master1 coredns]# cat Corefile 
custom.local:53 {
    file /etc/coredns/custom.local.db {
        # 每 30s 检查一次配置的 Serial,若该值有变更则重载整个 Zone 的配置。
        reload 30s
    }
}
.:53 {
    # 启用错误日志
    errors
    # 启用健康检查 api
    health {
        lameduck 5s
    }
    # 启用 readiness 就绪 api
    ready
    hosts /etc/coredns/hosts.db {
        reload 10s
        fallthrough
    }
    # 启用 prometheus metrics 支持
    prometheus :9153
    forward . 202.102.128.68 223.5.5.5 223.6.6.6 {
        max_concurrent 1000
    }
    # 启用前端缓存,缓存的 TTL 设为 30
    cache 30
    # 检测并停止死循环解析
    loop
    # 支持动态更新 Corefile
    reload 10s
    # 随机化 A/AAAA/MX 记录的顺序以实现负载均衡
    loadbalance
}

[root@master1 coredns]# cat custom.local.db 
$ORIGIN custom.local.
@   3600  IN    SOA sns.dns.icann.org. noc.dns.icann.org. (
                2020073102 ; 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.
​
@                 IN A     192.168.1.13
www               IN A     192.168.1.13
rook-ceph-mgr-dashboard IN A    192.168.10.11

[root@master1 coredns]# cat hosts.db
# test
111.11.11.11 test.api.yw
127.0.0.1         localhost

运行容器

docker run -d --name coredns --restart=always \
   -v /app/coredns:/etc/coredns -p 53:53/udp   \
   registry.aliyuncs.com/google_containers/coredns:1.8.6  \
   -conf /etc/coredns/Corefile

测试

nslookup

[root@master1 coredns]# nslookup test.api.yw 192.168.100.200 
Server:     192.168.100.200
Address:    192.168.100.200#53
​
Name:   test.api.yw
Address: 111.11.11.11
​
​


0

评论区