1 min read

setup coredns on ubuntu

setup coredns on ubuntu
Photo by Nastya Dulhiier / Unsplash

intro

  • dnsmasq
  • unbound
  • coredns

dnsmasq 不支持非 53 端口;unbound 功能强大,配置较为繁琐;coredns 为云原生项目,功能强大,配置简单。


coredns

https://github.com/coredns/coredns/releases

config

coredns.service

[Unit]
Description=Coredns .
After=network.target

[Service]
Type=simple
Restart=always
ExecStart=/usr/local/bin/coredns -conf /home/pi/workspace/coredns/config.cfg

[Install]
WantedBy=multi-user.target

config.cfg

. { 
    log
    cache 300

    # aliyun
    forward tmall.com 223.5.5.5
    forward taobao.com 223.5.5.5
    forward alipay.com 223.5.5.5
    forward alicdn.com 223.5.5.5
    forward aliyun.com 223.5.5.5

    # qcloud
    forward jd.com 119.28.28.28
    forward qq.com 119.28.28.28
    forward weixin.com 119.28.28.28
    forward tecent.com 119.28.28.28

    # other
    forward mi.com 119.29.29.29
    forward xiaomi.com 119.29.29.29
    forward netease.com 119.29.29.29
    forward bilibili.com 119.29.29.29

    # default
    forward . 127.0.0.1:1053    
}

scripts

$ systemctl stop systemd-resolved
$ systemctl disable systemd-resolved
$ systemctl start coredns.service
$ systemctl enable coredns.service