dig详解
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了dig详解相关的知识,希望对你有一定的参考价值。
[[email protected] ~]# dig www.a.com
; <<>> DiG 9.2.4 <<>> www.a.com
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 25746
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 6, ADDITIONAL: 6
;; QUESTION SECTION:
;www.aslibra.com. IN A
;; ANSWER SECTION:
www.aslibra.com. 900 IN A 222.76.215.25
;; AUTHORITY SECTION:
aslibra.com. 33024 IN NS k8.hkidc.com.
aslibra.com. 33024 IN NS b.hkidc.com.
aslibra.com. 33024 IN NS j6.hkidc.com.
aslibra.com. 33024 IN NS nidc.com.
aslibra.com. 33024 IN NS ns5.hkidc.com.
aslibra.com. 33024 IN NS a.hkidc.com.
;; ADDITIONAL SECTION:
k8.hkidc.com. 55596 IN A 125.65.112.32
b.hkidc.com. 53594 IN A 221.122.64.81
j6.hkidc.com. 54375 IN A 222.76.219.74
nidc.com. 53598 IN A 221.122.64.81
ns5.hkidc.com. 55596 IN A 222.76.219.81
a.hkidc.com. 53594 IN A 125.65.112.32
;; Query time: 71 msec
;; SERVER: 211.99.25.1#53(211.99.25.1)
;; WHEN: Mon Jun 1 12:05:17 2009
;; MSG SIZE rcvd: 268
; <<>> DiG 9.2.4 <<>> www.163.com
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 46550
;; flags: qr rd ra; QUERY: 1, ANSWER: 11, AUTHORITY: 2, ADDITIONAL: 2
;; QUESTION SECTION:
;www.163.com. IN A
;; ANSWER SECTION:
www.163.com. 51561 IN CNAME www.cache.gslb.netease.com.
www.cache.gslb.netease.com. 1604 IN A 61.135.253.16
www.cache.gslb.netease.com. 1604 IN A 61.135.253.17
www.cache.gslb.netease.com. 1604 IN A 61.135.253.18
www.cache.gslb.netease.com. 1604 IN A 61.135.253.9
www.cache.gslb.netease.com. 1604 IN A 61.135.253.10
www.cache.gslb.netease.com. 1604 IN A 61.135.253.11
www.cache.gslb.netease.com. 1604 IN A 61.135.253.12
www.cache.gslb.netease.com. 1604 IN A 61.135.253.13
www.cache.gslb.netease.com. 1604 IN A 61.135.253.14
www.cache.gslb.netease.com. 1604 IN A 61.135.253.15
;; AUTHORITY SECTION:
gslb.netease.com. 1604 IN NS gslb1.netease.com.
gslb.netease.com. 1604 IN NS gslb2.netease.com.
;; ADDITIONAL SECTION:
gslb1.netease.com. 15896 IN A 61.135.255.143
gslb2.netease.com. 15900 IN A 220.181.28.168
;; Query time: 56 msec
;; SERVER: 211.99.25.1#53(211.99.25.1)
;; WHEN: Mon Jun 1 12:29:51 2009
;; MSG SIZE rcvd: 298
; <<>> DiG 9.2.4 <<>> www.163.com +trace
;; global options: printcmd
. 223628 IN NS e.root-servers.net.
. 223628 IN NS f.root-servers.net.
. 223628 IN NS g.root-servers.net.
. 223628 IN NS h.root-servers.net.
. 223628 IN NS i.root-servers.net.
. 223628 IN NS j.root-servers.net.
. 223628 IN NS k.root-servers.net.
. 223628 IN NS l.root-servers.net.
. 223628 IN NS m.root-servers.net.
. 223628 IN NS a.root-servers.net.
. 223628 IN NS b.root-servers.net.
. 223628 IN NS c.root-servers.net.
. 223628 IN NS d.root-servers.net.
;; Received 512 bytes from 211.99.25.1#53(211.99.25.1) in 65 ms
com. 172800 IN NS A.GTLD-SERVERS.NET.
com. 172800 IN NS B.GTLD-SERVERS.NET.
com. 172800 IN NS M.GTLD-SERVERS.NET.
com. 172800 IN NS F.GTLD-SERVERS.NET.
com. 172800 IN NS E.GTLD-SERVERS.NET.
com. 172800 IN NS D.GTLD-SERVERS.NET.
com. 172800 IN NS C.GTLD-SERVERS.NET.
com. 172800 IN NS H.GTLD-SERVERS.NET.
com. 172800 IN NS L.GTLD-SERVERS.NET.
com. 172800 IN NS I.GTLD-SERVERS.NET.
com. 172800 IN NS K.GTLD-SERVERS.NET.
com. 172800 IN NS J.GTLD-SERVERS.NET.
com. 172800 IN NS G.GTLD-SERVERS.NET.
;; Received 501 bytes from 192.203.230.10#53(e.root-servers.net) in 212 ms
163.com. 172800 IN NS ns3.nease.net.
163.com. 172800 IN NS ns4.nease.net.
;; Received 106 bytes from 192.5.6.30#53(A.GTLD-SERVERS.NET) in 293 ms
www.163.com. 86400 IN CNAME www.cache.gslb.netease.com.
gslb.netease.com. 18000 IN NS gslb1.netease.com.
gslb.netease.com. 18000 IN NS gslb2.netease.com.
;; Received 138 bytes from 61.135.255.138#53(ns4.nease.net) in 47 ms
.com .cn .net各种域名都从这里开始分配授权,比如 .com 授权给 (A-G).GTLD-SERVERS.NET.
(尝试做一下 dig www.163.org +trace,就会发现 .org 是分配给 a0.org.afilias-nst.info.等服务器 了)
这批服务器又授权 163.com给另外的机器
163.com. 172800 IN NS ns3.nease.net.
163.com. 172800 IN NS ns4.nease.net.
www.163.com. 86400 IN CNAME www.cache.gslb.netease.com.
我们trace检查www.cache.gslb.netease.com. :
; <<>> DiG 9.2.4 <<>> www.cache.gslb.netease.com. +trace
netease.com. 172800 IN NS ns3.nease.net.
netease.com. 172800 IN NS ns4.nease.net.
;; Received 121 bytes from 192.12.94.30#53(E.GTLD-SERVERS.NET) in 468 ms
gslb.netease.com. 18000 IN NS gslb1.netease.com.
gslb.netease.com. 18000 IN NS gslb2.netease.com.
;; Received 116 bytes from 61.135.255.138#53(ns4.nease.net) in 44 ms
www.cache.gslb.netease.com. 1800 IN A 220.181.28.53
www.cache.gslb.netease.com. 1800 IN A 220.181.28.54
www.cache.gslb.netease.com. 1800 IN A 220.181.28.212
www.cache.gslb.netease.com. 1800 IN A 220.181.28.50
www.cache.gslb.netease.com. 1800 IN A 220.181.28.51
www.cache.gslb.netease.com. 1800 IN A 220.181.28.52
gslb.netease.com. 1800 IN NS gslb2.netease.com.
gslb.netease.com. 1800 IN NS gslb1.netease.com.
;; Received 180 bytes from 61.135.255.143#53(gslb1.netease.com) in 20 ms
使用dig命令我们甚至可以给163.com画一个他们的域名分布图了 :)
小结一下: 1 DNS服务器会按等级授权给别的服务器解析域名 2 指定的是NS记录,同时会有该NS记录的域名的A记录指定 3 别名方式会再继续查询,一般本dns服务器不处理cdn应该可以别名到cdn功能的服务器处理 4 你可以方便的用dig检查dns服务器分配情况 引用 DNS的工作原理及过程分下面几个步骤: 第一步:客户机提出域名解析请求,并将该请求发送给本地的域名服务器。 第二步:当本地的域名服务器收到请求后,就先查询本地的缓存,如果有该纪录项,则本地的域名服务器就直接把查询的结果返回。 第三步:如果本地的缓存中没有该纪录,则本地域名服务器就直接把请求发给根域名服务器,然后根域名服务器再返回给本地域名服务器一个所查询域(根的子域)的主域名服务器的地址。 第四步:本地服务器再向上一步返回的域名服务器发送请求,然后接受请求的服务器查询自己的缓存,如果没有该纪录,则返回相关的下第五步:重复第四步,直到找到正确的纪录。 第六步:本地域名服务器把返回的结果保存到缓存,以备下一次使用,同时还将结果返回给客户机。
以上是关于dig详解的主要内容,如果未能解决你的问题,请参考以下文章