码迷,mamicode.com
首页 > 其他好文 > 详细

Centos7快速安装CoreDNS

时间:2019-10-12 10:49:10      阅读:167      评论:0      收藏:0      [点我收藏+]

标签:esc   col   plugin   arch   自动   abi   域名解析   文件   exe   

1、下载二进制文件

wget https://github.com/coredns/coredns/releases/download/v1.5.0/coredns_1.5.0_linux_amd64.tgz
tar zxf coredns_1.5.0_linux_amd64.tgz -C /usr/bin/

2、创建用户

useradd coredns -s /sbin/nologin

3、编辑/etc/coredns/Corefile

.:53 {
  # 绑定interface ip
  bind 127.0.0.1
  # 先走本机的hosts
  # https://coredns.io/plugins/hosts/
  hosts {
    # 自定义sms.service search.service 的解析
    # 因为解析的域名少我们这里直接用hosts插件即可完成需求
    # 如果有大量自定义域名解析那么建议用file插件使用 符合RFC 1035规范的DNS解析配置文件
    10.6.6.2 sms.service
    10.6.6.3 search.service
    # ttl
    ttl 60
    # 重载hosts配置
    reload 1m
    # 继续执行
    fallthrough
  }
  # file enables serving zone data from an RFC 1035-style master file.
  # https://coredns.io/plugins/file/
  # file service.signed service
  # 最后所有的都转发到系统配置的上游dns服务器去解析
  forward . /etc/resolv.conf
  # 缓存时间ttl
  cache 120
  # 自动加载配置文件的间隔时间
  reload 6s
  # 输出日志
  log
  # 输出错误
  errors
}

更新插件使用:https://github.com/coredns/coredns

4、编辑/usr/lib/systemd/system/coredns.service

[Unit]
Description=CoreDNS DNS server
Documentation=https://coredns.io
After=network.target

[Service]
PermissionsStartOnly=true
LimitNOFILE=1048576
LimitNPROC=512
CapabilityBoundingSet=CAP_NET_BIND_SERVICE
AmbientCapabilities=CAP_NET_BIND_SERVICE
NoNewPrivileges=true
User=coredns
ExecStart=/usr/bin/coredns -conf=/etc/coredns/Corefile
ExecReload=/bin/kill -SIGUSR1 $MAINPID
Restart=on-failure

[Install]
WantedBy=multi-user.target

5、启动coredns

systemctl enable coredns
systemctl start coredns
systemctl status coredns

 

Centos7快速安装CoreDNS

标签:esc   col   plugin   arch   自动   abi   域名解析   文件   exe   

原文地址:https://www.cnblogs.com/sandshell/p/11659900.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!