DNS主域控在境外,想将内网DNS解析由本地DNS解析.网络环境为内网,无法访问INTERNET.搭建完毕后发现无法解析需要forward那些zone.
bind版本:bind-9.11.4
起初配置非常顺利,通过以下命令,将intra.aaa.com的所有记录都抓取下来,并实现所有现有的A记录和CNAME等解析
dig -t axfr intra.aaa.com @192.168.31.67
当解析intra.aaa.com以外的域名解析时发生了错误.报错信息:
[root@dns01 ~]# nslookup ns1.aaa.com.
Server: 192.168.31.66
Address: 192.168.31.66#53
** server can't find ns1.aaa.com: SERVFAIL
但执行dig ns1.aaa.com. @192.168.31.67又是能解析到的
[root@dns01 ~]# dig ns1.aaa.com. @192.168.31.67
; <<>> DiG 9.11.4-P2-RedHat-9.11.4-9.P2.el7 <<>> ns1.aaa.com. @192.168.31.67
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 19091
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 2
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;ns1.aaa.com. IN A
;; ANSWER SECTION:
ns1.aaa.com. 86400 IN A 192.168.35.104
;; AUTHORITY SECTION:
aaa.com. 86400 IN NS ns1.aaa.com.
aaa.com. 86400 IN NS ns2.aaa.com.
;; ADDITIONAL SECTION:
ns2.aaa.com. 86400 IN A 192.168.31.21
;; Query time: 2 msec
;; SERVER: 192.168.31.67#53(192.168.31.67)
;; WHEN: Fri Jun 04 04:19:01 EDT 2021
;; MSG SIZE rcvd: 107
将所有配置全部复制到笔记本的vmware环境上.神奇的是用nslookup解析一切正常.
[root@dns01 ~]# nslookup ns1.aaa.com.
Server: 192.168.31.66
Address: 192.168.31.66#53
Non-authoritative answer:
Name: ns1.aaa.com
Address: 192.168.35.104
正当一头雾水的时候,发现用dig时会多很多信息.
显然是解析了根域和.com.
[root@dns01 ~]# dig ns1.aaa.com.
; <<>> DiG 9.11.4-P2-RedHat-9.11.4-9.P2.el7 <<>> ns1.aaa.com.
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 49509
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 13, ADDITIONAL: 15
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;ns1.aaa.com. IN A
;; ANSWER SECTION:
ns1.aaa.com. 86400 IN A 192.168.35.104
;; AUTHORITY SECTION:
com. 172798 IN NS b.gtld-servers.net.
com. 172798 IN NS a.gtld-servers.net.
com. 172798 IN NS k.gtld-servers.net.
com. 172798 IN NS i.gtld-servers.net.
com. 172798 IN NS g.gtld-servers.net.
com. 172798 IN NS h.gtld-servers.net.
com. 172798 IN NS d.gtld-servers.net.
com. 172798 IN NS m.gtld-servers.net.
com. 172798 IN NS l.gtld-servers.net.
com. 172798 IN NS e.gtld-servers.net.
com. 172798 IN NS c.gtld-servers.net.
com. 172798 IN NS j.gtld-servers.net.
com. 172798 IN NS f.gtld-servers.net.
;; ADDITIONAL SECTION:
a.gtld-servers.net. 172798 IN A 192.5.6.30
b.gtld-servers.net. 172798 IN A 192.33.14.30
c.gtld-servers.net. 172798 IN A 192.26.92.30
d.gtld-servers.net. 172798 IN A 192.31.80.30
e.gtld-servers.net. 172798 IN A 192.12.94.30
f.gtld-servers.net. 172798 IN A 192.35.51.30
g.gtld-servers.net. 172798 IN A 192.42.93.30
h.gtld-servers.net. 172798 IN A 192.54.112.30
i.gtld-servers.net. 172798 IN A 192.43.172.30
j.gtld-servers.net. 172798 IN A 192.48.79.30
k.gtld-servers.net. 172798 IN A 192.52.178.30
l.gtld-servers.net. 172798 IN A 192.41.162.30
m.gtld-servers.net. 172798 IN A 192.55.83.30
a.gtld-servers.net. 172798 IN AAAA 2001:503:a83e::2:30
;; Query time: 2674 msec
;; SERVER: 192.168.31.66#53(192.168.31.66)
;; WHEN: Fri Jun 04 04:24:59 EDT 2021
;; MSG SIZE rcvd: 519
之后所有的解析都正常了.但只要断网后重启named服务,故障又重现了.
显然是因为匹配到forward后,先走了根域的解析没有直接走forwarders 的地址.
named.rfc1912.zones中关于aaa.com.的配置如下
zone "aaa.com" IN {
type forward;
forward only;
forwarders { 192.168.31.67;};
};
显然这段是没问题的.
找了很多资料最后发现named.conf中有2个参数,可能存在问题.
// dnssec-enable yes;
// dnssec-validation yes;
关于dnssec的解释如下:
DNSSEC全称Domain Name System Security Extensions,即DNS安全扩展,是由IETF提供的一系列DNS安全认证的机制(可参考RFC2535)。它提供一种可以验证应答信息真实性和完整性的机制,利用密码技术,使得域名解析服务器可以验证它所收到的应答(包括域名不存在的应答)是否来自于真实的服务器,或者是否在传输过程中被篡改过。
dnssec-enable: 是否支持DNSSEC开关,默认为yes。
dnssec-validation: 是否进行DNSSEC确认开关,默认为no。
原先是注释了这两个参数,以为named.conf中默认是yes那么注释了后就是no.
万万没想到注释了dnssec-enable其实还是yes
然后把这两行的注释都去掉,改为了no
dnssec-enable no;
dnssec-validation no;
刷新后一切恢复正常
[root@dns01 ~]# named-checkconf
[root@dns01 ~]# rndc reload
server reload successful
[root@dns01 ~]# nslookup ns1.aaa.com.
Server: 192.168.31.66
Address: 192.168.31.66#53
Non-authoritative answer:
Name: ns1.aaa.com
Address: 192.168.35.104
[root@dns01 ~]# dig ns1.aaa.com.
; <<>> DiG 9.11.4-P2-RedHat-9.11.4-9.P2.el7 <<>> ns1.aaa.com.
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 57251
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;ns1.aaa.com. IN A
;; ANSWER SECTION:
ns1.aaa.com. 86398 IN A 192.168.35.104
;; Query time: 0 msec
;; SERVER: 192.168.31.66#53(192.168.31.66)
;; WHEN: Fri Jun 04 04:48:36 EDT 2021
;; MSG SIZE rcvd: 59