在Linux和Windows下均可以用nslookup命令來查詢域名的解析結果,如圖1-13所示。linux
在Linux系統中還可使用dig命名來查詢DNS的解析過程,以下所示:
[junshan@v101055.sqa.cm4 admin]$ dig www.taobao.com服務器
; <<>> DiG 9.3.6-P1-RedHat-9.3.6-4.P1.el5 <<>> www.taobao.com
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 16903
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 3, ADDITIONAL: 3.net
;; QUESTION SECTION:
;www.taobao.com. IN Acode
;; ANSWER SECTION:
www.taobao.com. 1542 IN CNAME www.gslb.taobao.com.
www.gslb.taobao.com. 130 IN A 115.238.23.251
www.gslb.taobao.com. 130 IN A 115.238.23.241server
;; AUTHORITY SECTION:
gslb.taobao.com. 70371 IN NS gslbns3.taobao.com.
gslb.taobao.com. 70371 IN NS gslbns1.taobao.com.
gslb.taobao.com. 70371 IN NS gslbns2.taobao.com.get
;; ADDITIONAL SECTION:
gslbns1.taobao.com. 452 IN A 121.0.23.218
gslbns2.taobao.com. 452 IN A 115.124.17.70
gslbns3.taobao.com. 452 IN A 110.75.3.193cmd
;; Query time: 5 msec
;; SERVER: 10.232.2.254#53(10.232.2.254)
;; WHEN: Sun Feb 12 19:19:05 2012
;; MSG SIZE rcvd: 201域名
結果的第1行輸出了當前Linux的版本號,第2行說明能夠增長可選參數printcmd,若是加上printcmd,打印出來的結果以下:
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 58602
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0io
;; QUESTION SECTION:
;printcmd. IN Aclass
;; AUTHORITY SECTION:
. 10800 IN SOA a.root-servers.net. nstld. verisign-grs.com. 2012021200 1800 900 604800 86400
;; Query time: 208 msec
;; SERVER: 10.232.2.254#53(10.232.2.254)
;; WHEN: Sun Feb 12 19:20:59 2012
;; MSG SIZE rcvd: 101
「QUESTION SECTION」部分表示當前查詢的域名是一個 A 記錄,「ANSWER SECTION」部分返回了這個域名由CNAME到www.gslb.taobao.com,返回了這個域名對應的IP地址。
還可經過增長+trace參數跟蹤這個域名的解析過程,以下所示:
[junshan@v101055.sqa.cm4 admin]$ dig www.taobao.com +trace
; <<>> DiG 9.3.6-P1-RedHat-9.3.6-4.P1.el5 <<>> www.taobao.com +trace
;; global options: printcmd
. 449398 IN NS k.root-servers.net.
. 449398 IN NS l.root-servers.net.
. 449398 IN NS m.root-servers.net.
. 449398 IN NS a.root-servers.net.
. 449398 IN NS b.root-servers.net.
. 449398 IN NS c.root-servers.net.
. 449398 IN NS d.root-servers.net.
. 449398 IN NS e.root-servers.net.
. 449398 IN NS f.root-servers.net.
. 449398 IN NS g.root-servers.net.
. 449398 IN NS h.root-servers.net.
. 449398 IN NS i.root-servers.net.
. 449398 IN NS j.root-servers.net.
;; Received 272 bytes from 10.232.2.254#53(10.232.2.254) in 0 ms
com. 172800 IN NS a.gtld-servers.net.
com. 172800 IN NS b.gtld-servers.net.
com. 172800 IN NS c.gtld-servers.net.
com. 172800 IN NS d.gtld-servers.net.
com. 172800 IN NS e.gtld-servers.net.
com. 172800 IN NS f.gtld-servers.net.
com. 172800 IN NS g.gtld-servers.net.
com. 172800 IN NS h.gtld-servers.net.
com. 172800 IN NS i.gtld-servers.net.
com. 172800 IN NS j.gtld-servers.net.
com. 172800 IN NS k.gtld-servers.net.
com. 172800 IN NS l.gtld-servers.net.
com. 172800 IN NS m.gtld-servers.net.
;; Received 492 bytes from 193.0.14.129#53(k.root-servers.net) in 607 ms
taobao.com. 172800 IN NS ns1.taobao.com.
taobao.com. 172800 IN NS ns2.taobao.com.
taobao.com. 172800 IN NS ns3.taobao.com.
;; Received 134 bytes from 192.5.6.30#53(a.gtld-servers.net) in 250 ms
www.taobao.com. 1800 IN CNAME www.gslb.taobao.com.
gslb.taobao.com. 86400 IN NS gslbns2.taobao.com.
gslb.taobao.com. 86400 IN NS gslbns3.taobao.com.
gslb.taobao.com. 86400 IN NS gslbns1.taobao.com.
;; Received 169 bytes from 110.75.1.19#53(ns1.taobao.com) in 0 ms
上面清楚地顯示了整個域名是如何發起和解析的,從根域名(.)到gTLD Server(.com.)再到Name Server(taobao.com.)的整個過程都顯示出來了。還能夠看出DNS的服務器有多個備份,能夠從任何一臺查詢到解析結果。