遇到的问题:我配置的bind (dns服务器ip:192.168.10.74)可以解析出我自定的域名,但是不能解析出公网的域名,如
[root@localhost named]#
dig @192.168.10.74
; <<>> DiG 9.7.3-RedHat-9.7.3-2.el6 <<>> @192.168.10.74
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 36297
;; flags: qr rd ra;
QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;. IN A
;; Query time: 0 msec
;; SERVER: 192.168.10.74#53(192.168.10.74)
;; WHEN: Wed Dec 16 15:24:36 2015
;; MSG SIZE rcvd: 31
经过了几番周折才发现我的/usr/local/bind9.9.2/var/named/named.root内容为:
[root@localhost named]# vim named.root
; <<>> DiG 9.7.3-RedHat-9.7.3-2.el6 <<>>
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 39277
;; flags: qr rd ra; QUERY: 1, ANSWER: 13, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;. IN NS
;; ANSWER SECTION:
. 1898 IN NS g.root-servers.net.
. 1898 IN NS b.root-servers.net.
. 1898 IN NS k.root-servers.net.
. 1898 IN NS j.root-servers.net.
. 1898 IN NS e.root-servers.net.
. 1898 IN NS d.root-servers.net.
. 1898 IN NS c.root-servers.net.
. 1898 IN NS f.root-servers.net.
. 1898 IN NS a.root-servers.net.
. 1898 IN NS m.root-servers.net.
. 1898 IN NS l.root-servers.net.
. 1898 IN NS i.root-servers.net.
. 1898 IN NS h.root-servers.net.
;; Query time: 10 msec
;; SERVER: 123.125.81.6#53(123.125.81.6)
;; WHEN: Tue Jul 14 12:03:22 2015
;; MSG SIZE rcvd: 228
只有NS记录没有A记录,于是重新生成:
dig >named.root
dig >
named.ca
发现named.ca中比named.root中多了A记录,
[root@localhost named]# vim named.ca
; <<>> DiG 9.7.3-RedHat-9.7.3-2.el6 <<>>
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 20266
;; flags: qr rd; QUERY: 1, ANSWER: 13, AUTHORITY: 0, ADDITIONAL: 13
;; WARNING: recursion requested but not available
;; QUESTION SECTION:
;. IN NS
;; ANSWER SECTION:
. 23989 IN NS j.root-servers.net.
. 23989 IN NS a.root-servers.net.
. 23989 IN NS k.root-servers.net.
. 23989 IN NS d.root-servers.net.
. 23989 IN NS g.root-servers.net.
. 23989 IN NS m.root-servers.net.
. 23989 IN NS h.root-servers.net.
. 23989 IN NS c.root-servers.net.
. 23989 IN NS e.root-servers.net.
. 23989 IN NS f.root-servers.net.
. 23989 IN NS i.root-servers.net.
. 23989 IN NS l.root-servers.net.
. 23989 IN NS b.root-servers.net.
;; ADDITIONAL SECTION:
a.root-servers.net. 23989 IN A 198.41.0.4
a.root-servers.net. 23989 IN AAAA 2001:503:ba3e::2:30
b.root-servers.net. 23989 IN A 192.228.79.201
b.root-servers.net. 23989 IN AAAA 2001:500:84::b
c.root-servers.net. 23989 IN A 192.33.4.12
c.root-servers.net. 23989 IN AAAA 2001:500:2::c
d.root-servers.net. 23989 IN A 199.7.91.13
d.root-servers.net. 23989 IN AAAA 2001:500:2d::d
e.root-servers.net. 23989 IN A 192.203.230.10
f.root-servers.net. 23989 IN A 192.5.5.241
f.root-servers.net. 23989 IN AAAA 2001:500:2f::f
g.root-servers.net. 23989 IN A 192.112.36.4
h.root-servers.net. 23989 IN A 198.97.190.53
;; Query time: 18 msec
;; SERVER: 60.28.227.9#53(60.28.227.9)
;; WHEN: Wed Dec 16 15:08:31 2015
;; MSG SIZE rcvd: 496
于是用生成的named.ca替换我原来的named.root,或者直接就用named.ca,且在named.config中把named.root改成named.ca就可以了,重新加载配置后生效,再dig:
[root@localhost etc]# dig @192.168.10.74
; <<>> DiG 9.7.3-RedHat-9.7.3-2.el6 <<>> @192.168.10.74
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 6273
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 5, ADDITIONAL: 5
;; QUESTION SECTION:
;. IN A
;; ANSWER SECTION:
. 1200 IN CNAME
300 IN A 61.135.169.121
300 IN A 61.135.169.125
;; AUTHORITY SECTION:
a.shifen.com. 1200 IN NS ns4.a.shifen.com.
a.shifen.com. 1200 IN NS ns3.a.shifen.com.
a.shifen.com. 1200 IN NS ns5.a.shifen.com.
a.shifen.com. 1200 IN NS ns2.a.shifen.com.
a.shifen.com. 1200 IN NS ns1.a.shifen.com.
;; ADDITIONAL SECTION:
ns1.a.shifen.com. 1200 IN A 61.135.165.224
ns2.a.shifen.com. 1200 IN A 180.149.133.241
ns3.a.shifen.com. 1200 IN A 61.135.162.215
ns4.a.shifen.com. 1200 IN A 115.239.210.176
ns5.a.shifen.com. 1200 IN A 119.75.222.17
;; Query time: 2436 msec
;; SERVER: 192.168.10.74#53(192.168.10.74)
;; WHEN: Wed Dec 16 15:16:05 2015
;; MSG SIZE rcvd: 260
成功了,bind详细的配置请参考我的:
http://blog.chinaunix.net/uid-30199261-id-5131038.html
原来dns服务器默认是可以解析公网地址的,可能会有点慢吧,想更快点,可配置forwarder转发,我没试验过不知道是否可以,
可参考转载
http://m.blog.csdn.net/blog/tianwei7518/45061705 共同学习