zoukankan      html  css  js  c++  java
  • docker部署coredns

    示例:

    [root@corends coredns]# cd /home/coredns/
    [root@corends coredns]# ls -al
    total 12
    drwxr-xr-x  2 root root   61 Sep 12 11:40 .
    drwxr-xr-x. 4 root root   51 Sep 16 16:06 ..
    -rwxr-xr-x  1 root root  120 Sep  6 11:33 Corefile
    -rwxr-xr-x  1 root root 1522 Sep 12 11:40 hosts
    -rw-r--r--  1 root root  199 Sep  6 11:33 install-coredns.sh
    [root@corends coredns]# cat install-coredns.sh 
    #!/bin/bash
    
    docker run -d 
      --restart always 
      --name coredns 
      -p 53:53/tcp 
      -p 53:53/udp 
      -v /home/coredns/hosts:/etc/hosts 
      -v /home/coredns/Corefile:/Corefile 
      coredns/coredns
    [root@corends coredns]# cat Corefile 
    .:53 {
        hosts {
            fallthrough
        }
        forward . 202.96.128.86 114.114.114.114 8.8.8.8
        errors
        cache
    }
    [root@corends coredns]# cat hosts 
    # 根据实际需要修改
    192.168.0.200 devgz.yaohjk.com
    192.168.0.200 devboss.yaohjk.com
    192.168.0.200 devlogin.yaohjk.com
    192.168.0.200 devpay.yaohjk.com
    192.168.0.200 devwx.yaohjk.com
    
    192.168.0.200 gz.yaohuiw.net
    192.168.0.200 boss.yaohuiw.net
    192.168.0.200 login.yaohuiw.net
    192.168.0.200 pay.yaohuiw.net
    192.168.0.200 wx.yaohuiw.net
    
    
    192.168.0.199 gz.yaohjk.com
    192.168.0.199 boss.yaohjk.com
    192.168.0.199 login.yaohjk.com
    192.168.0.199 pay.yaohjk.com
    192.168.0.199 wx.yaohjk.com
    
    192.168.0.198 boss.yaohuiw.xyz
    192.168.0.198 gz.yaohuiw.xyz
    192.168.0.198 login.yaohuiw.xyz
    192.168.0.198 pay.yaohuiw.xyz
    192.168.0.198 wx.yaohuiw.xyz
    [root@corends coredns]#

    验证:

    [root@test2 ~]# cat /etc/resolv.conf 
    # Generated by NetworkManager
    nameserver 192.168.0.246
    
    
    
    [root@test2 ~]# nslookup devgz.yaohjk.com
    Server:        192.168.0.246
    Address:    192.168.0.246#53
    
    Name:    devgz.yaohjk.com
    Address: 192.168.0.200
    ** server can't find devgz.yaohjk.com: NXDOMAIN
    
    [root@test2 ~]# nslookup gz.yaohjk.com
    Server:        192.168.0.246
    Address:    192.168.0.246#53
    
    Name:    gz.yaohjk.com
    Address: 192.168.0.199
  • 相关阅读:
    Nagios利用NSClient++监控Windows主机
    Nagios监控Windows的网卡流量
    Nagios 监控Windows服务器(详细篇)
    ODB学习笔记之基础环境搭建
    用Kindle阅读PDF最简单的3个方法!
    RocketMQ吐血总结
    RocketMQ使用
    掌握 analyze API,一举搞定 Elasticsearch 分词难题
    ElasticSearch5.3安装IK分词器并验证
    Kibana server is not ready yet出现的原因
  • 原文地址:https://www.cnblogs.com/jiangwenhui/p/11912318.html
Copyright © 2011-2022 走看看