麒麟系统部署CoreDns与配置

场景:

       业务系统使用的泛域名模式,并且会随机产生泛域名,所以现在需要使用CoreDns搭建一个新的域名解析服务提供给这个业务系统使用。


CoreDNS下载地址:

https://github.com/coredns/coredns/releases/tag/v1.11.0https://github.com/coredns/coredns/releases/tag/v1.11.0

安装步骤:

1.解压缩安装包:使用以下命令解压缩下载的安装包。

tar -xzvf coredns_1.11.0_linux_amd64.tgz

2.入解压后的目录:使用以下命令进入解压后的目录。

cd coredns_1.11.0_linux_amd64

3.将CoreDNS二进制文件复制到/usr/local/bin,添加执行权限。

cp coredns /usr/local/bin/
chmod +x /usr/local/bin/coredns
设置systemctl启动脚本:

创建一个名为coredns.service的文件。

vim /etc/systemd/system/coredns.service

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

[Service]
ExecStart=/usr/local/bin/coredns -conf /etc/coredns/Corefile
Restart=on-failure

[Install]
WantedBy=multi-user.target
设置CoreDns配置文件:

创建一个Corefile的文件在/etc/coredns/

. {
    forward . 8.8.8.8 #除了下面的泛域名都交给这个IP的DNS服务器解析。
}

brother.com:53 {
    errors
    template ANY AAAA {
        rcode NXDOMAIN
    }
    template IN A *.brother.com {
        match .*.brother.com
        answer "{{ .Name }} 60 IN A 192.168.1.99"  #访问这个泛域名全部返回99
        fallthrough
    }
    cache 30

    file /etc/coredns/brother.com.zone #A记录配置文件
}
设置CoreDns解析文件:

创建/etc/coredns/brother.com.zone

vim /etc/coredns/brother.com.zone

$TTL 3600
@       IN      SOA     ns1.example.com. admin.example.com. (
                              2023081401 ; Serial
                              3600       ; Refresh
                              1800       ; Retry
                              604800     ; Expire
                              86400 )    ; Minimum TTL

        IN      NS      ns1.example.com.

*.brother.com.    IN      A       192.168.1.99
 启动并验证:

1.在DNS服务器启动服务:
 

systemctl start coredns

2.在客户机器上配置dns服务器地址:
 

vim /etc/resolv.conf
nameserver 192.168.1.99

3.在客户机器上使用随机域名验证:
 

dig d32rd23r2r2.brother.com
#或者
nslookup dwewe12e32r3.brother.com
#域名随机输入

结果:

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值