• Centos7 安装CoreDNS


    Centos7 安装CoreDNS

    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 0.0.0.0
      
      # 先走本机的hosts,  https://coredns.io/plugins/hosts/
      hosts {
        # 解析的域名少,直接用hosts插件即可.
        # 大量自定义域名解析,建议使用file插件使用.
        192.168.10.50 test.linux08.com  
        192.168.10.51 www.linux08.com
    
        # 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
    
    6、测试coredns
    yum install dnstop bind-utils -y
    
    执行以下命令;
    dig @192.168.10.50 test.linux08.com
    dig @192.168.10.50 www.linux08.com
    dig @192.168.10.50 www.baidu.com
    
    # 服务端结果:
    [root@bj-dns ~]# dnstop eth0
    Queries: 0 new, 4 total                                                                                                                             Fri Apr  8 18:13:18 2022
    
    Sources           Count      %   cum%
    ------------- --------- ------ ------
    192.168.10.73         3   75.0   75.0
    192.168.10.50         1   25.0  100.0
    
  • 相关阅读:
    SqlDependency和SqlCacheDependency的若干说明
    sublime 3 随笔
    [有得]解决redmine写操作很慢的问题
    Java双重循环
    使用 Docker 打包 Rust Web 服务
    Centos8.3、hadoop-2.6.4 简单的日志分析实验
    广域网数据交换的三种方式
    计算机的起源与发展
    推荐两款生成数据库表结构说明文档工具
    Centos8.3、docker部署springboot项目实战记录
  • 原文地址:https://www.cnblogs.com/zhenxing06/p/16119063.html
Copyright © 2020-2023  润新知