假定配置内容如下
nameserver 192.168.0.2
nameserver 127.0.0.1
DNS解析流程
1. 查询192.168.0.2,如果服务器可以连接,则响应对应ip或者响应无记录。
2. 如果192.168.0.2服务器不可达,则查询127.0.0.1
注意:192.168.0.2网络可达,但没有查询出对应dns记录,不会继续查询下面的dns服务器了。
可采用host指令检查解析记录,参考效果
# host -v www.baidu.com
Trying "www.baidu.com"
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 30232
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;www.baidu.com. IN A
;; ANSWER SECTION:
www.baidu.com. 134 IN CNAME www.a.shifen.com.
www.a.shifen.com. 134 IN A 14.215.177.39
www.a.shifen.com. 134 IN A 14.215.177.38
Received 90 bytes from 223.5.5.5#53 in 22 ms
Trying "www.a.shifen.com"
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 45392
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0
;; QUESTION SECTION:
;www.a.shifen.com. IN AAAA
;; AUTHORITY SECTION:
a.shifen.com. 600 IN SOA ns1.a.shifen.com. baidu_dns_master.baidu.com. 2109090004 5 5 2592000 3600
Received 97 bytes from 127.0.0.1#53 in 581 ms
Trying "www.a.shifen.com"
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 24903
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0
;; QUESTION SECTION:
;www.a.shifen.com. IN MX
;; AUTHORITY SECTION:
a.shifen.com. 600 IN SOA ns1.a.shifen.com. baidu_dns_master.baidu.com. 2109090004 5 5 2592000 3600
Received 97 bytes from 127.0.0.1#53 in 25 ms