文章开始
文章结尾
上传coredns文件
解压
tar -zxvf coredns_1.11.1_linux_arm64.tgz在当前目录创建配置文件
vi Corefile上游服务器
.:53 {
forward . 8.8.8.8:53
log
}.:53 {
forward . 8.8.8.8:53
hosts /home/coredns/hosts
log
}vi /home/coredns/hosts
172.10.162.32 guiyun.test
172.10.162.31 admin.guiyun.test最好是使用docker拉取coredns镜像
docker search coredns
docker run -it -d --name coredns --net=host -v /etc/coredns:/etc/coredns/ coredns/coredns:latest -conf /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
}
nslookup
>
> set q=mx
>
> deali.cn
S
Server: 8.8.8.8
A
Address: 8.8.8.8#53
N
Non-authoritative answer:
d
deali.cn mail exchanger = 5 deali.cn.
A
Authoritative answers can be found from:
引入区域文件到 CoreDNS 中进行权威服务
# 最后两行定义 www.example.org. 具有两个地址: 127.0.0.1、:: 1
cat > db.example.org <<'EOF'
$ORIGIN example.org.
@ 3600 IN SOA sns.dns.icann.org. noc.dns.icann.org. (
2017042745 ; serial
7200 ; refresh (2 hours)
3600 ; retry (1 hour)
1209600 ; expire (2 weeks)
3600 ; minimum (1 hour)
)
3600 IN NS a.iana-servers.net.
3600 IN NS b.iana-servers.net.
www IN A 127.0.0.1
IN AAAA ::1
EOF
# Corefile 中新增如下配置段 ...
example.org {
file db.example.org
log
}
# 启动 CoreDNS 并使用 dig 验证
$ dig www.example.org AAAA
# www.example.org. 3600 IN AAAA ::1
————————————————
版权声明:本文为CSDN博主「weixin_45015255」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/weixin_45015255/article/details/117250024
; qing.su 域名 DNS 区域文件 (NS 记录指向本域)
$ORIGIN qing.su.
$TTL 3600 ; 默认 TTL 1 小时
; SOA 记录 - 主域名服务器设为 ns1.qing.su
@ IN SOA ns1.qing.su. admin.qing.su. (
2024071101 ; 序列号 (修改时递增)
7200 ; 刷新 2 小时
3600 ; 重试 1 小时
1209600 ; 过期 2 周
3600 ; 最小 TTL 1 小时
)
; >>>>>> 核心配置:域名服务器记录 <<<<<<
; NS 记录指向本域名下的服务器
@ IN NS ns1.qing.su. ; 主域名服务器
@ IN NS ns2.qing.su. ; 辅助域名服务器
; 为 NS 服务器提供 A 记录(必需)
ns1 IN A 12.34.56.1 ; 替换为 ns1 的真实 IP
ns2 IN A 12.34.56.2 ; 替换为 ns2 的真实 IP
; >>>>>> 您提供的解析记录配置 <<<<<<
; 邮件服务器 A 记录
mx IN A 12.34.56.78 ; 邮件服务器 IP
; MX 记录
@ IN MX 10 mx.qing.su.
; SPF 认证
@ IN TXT "v=spf1 a mx -all"
mx IN TXT "v=spf1 a -all"
; DMARC 策略
_dmarc IN TXT "v=DMARC1; p=reject; rua=mailto:postmaster@qing.su; ruf=mailto:postmaster@qing.su"
; 服务别名
mta-sts IN CNAME mx.qing.su.
autoconfig IN CNAME mx.qing.su.
autodiscover IN CNAME mx.qing.su.
mail IN CNAME mx.qing.su.
; >>>>>> 可选附加记录 <<<<<<
; 域名服务器 IPv6 支持(如有)
; ns1 IN AAAA 2001:db8::1
; ns2 IN AAAA 2001:db8::2
; 邮件服务器 IPv6(如有)
; mx IN AAAA 2001:db8::78
; Web 服务器记录(示例)
; www IN A 12.34.56.79