搞不懂这个dig结果

Web、Mail、Ftp、DNS、Proxy、VPN、Samba、LDAP 等基础网络服务
回复
pengsir
帖子: 120
注册时间: 2015-07-24 8:29
系统: ubuntu

搞不懂这个dig结果

#1

帖子 pengsir » 2015-12-20 15:14

我的/etc/hosts设置文件

220.181.57.217 baidu.com

为何dig的结果是

dig +trace baidu.com

; <<>> DiG 9.9.5-9+deb8u3-Debian <<>> +trace baidu.com
;; global options: +cmd
. 479168 IN NS c.root-servers.net.
. 479168 IN NS d.root-servers.net.
. 479168 IN NS f.root-servers.net.
. 479168 IN NS a.root-servers.net.
. 479168 IN NS l.root-servers.net.
. 479168 IN NS j.root-servers.net.
. 479168 IN NS e.root-servers.net.
. 479168 IN NS b.root-servers.net.
. 479168 IN NS g.root-servers.net.
. 479168 IN NS m.root-servers.net.
. 479168 IN NS h.root-servers.net.
. 479168 IN NS i.root-servers.net.
. 479168 IN NS k.root-servers.net.
. 479168 IN RRSIG NS 8 0 518400 20151229170000 20151219160000 62530 . oOJd1U9xP2VwRw/QaOyTRrRS0fqNBNvJcH4NMpEx5xodWsKUX3G1Azf6 DBZoEMdqlu8LQn/BgIUD54hzh/Z58+hus1CHmbN+ic6Ys6Fz1PRXtbts lfX9PjQ/snk2KfkWc/+U5Zouild611+ynR612cNm21Va9wigdywDlTuu Sws=
;; Received 397 bytes from 192.168.1.1#53(192.168.1.1) in 5502 ms

com. 172800 IN NS m.gtld-servers.net.
com. 172800 IN NS l.gtld-servers.net.
com. 172800 IN NS k.gtld-servers.net.
com. 172800 IN NS j.gtld-servers.net.
com. 172800 IN NS i.gtld-servers.net.
com. 172800 IN NS h.gtld-servers.net.
com. 172800 IN NS g.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 b.gtld-servers.net.
com. 172800 IN NS a.gtld-servers.net.
com. 86400 IN DS 30909 8 2 E2D3C916F6DEEAC73294E8268FB5885044A833FC5459588F4A9184CF C41A5766
com. 86400 IN RRSIG DS 8 1 86400 20151230050000 20151220040000 62530 . mW3cdOQcjyRga66RZ81q0CWdSYD8nOxNCDoCCTeQlJMEq0Fi9l4gwUuX IAEB/JO+KWYA9xX8VF1oTuqfrVQyDId7vRqI6DO008T1LGyi/nM+RXMc 5lTXPtROTNwxwz+fbhARdysttbtLG9ZWOoI3m4nh4Q2ufVtuELEwVXAH VT8=
;; Received 733 bytes from 192.58.128.30#53(j.root-servers.net) in 5290 ms

baidu.com. 172800 IN NS dns.baidu.com.
baidu.com. 172800 IN NS ns2.baidu.com.
baidu.com. 172800 IN NS ns3.baidu.com.
baidu.com. 172800 IN NS ns4.baidu.com.
baidu.com. 172800 IN NS ns7.baidu.com.
CK0POJMG874LJREF7EFN8430QVIT8BSM.com. 86400 IN NSEC3 1 1 0 - CK0Q1GIN43N1ARRC9OSM6QPQR81H5M9A NS SOA RRSIG DNSKEY NSEC3PARAM
CK0POJMG874LJREF7EFN8430QVIT8BSM.com. 86400 IN RRSIG NSEC3 8 2 86400 20151226055326 20151219044326 51797 com. SpiAXslRV5sdT+l4wrsYTn/W3dH1UJcmd2eO0cXluTAkaS9TDp4an0qd jNxu6U51N4K09aaj8tkSqPi4JlGFUV9Yx3c//ytPaqWt7dOmUaEvnihL egFcLcTL6DD7RVvEoLT6aANmg8jDS9pQXjFIR3wDRDqLvfs6L96uqGvc V1w=
HPVV2B5N85O7HJJRB7690IB5UVF9O9UA.com. 86400 IN NSEC3 1 1 0 - HPVV9UNFR23OVV2EH3NNTJ1A7JE3ETFH NS DS RRSIG
HPVV2B5N85O7HJJRB7690IB5UVF9O9UA.com. 86400 IN RRSIG NSEC3 8 2 86400 20151224055400 20151217044400 51797 com. lgVCSGarWuNm8H3sGsL67h0zDnhl8ZaH0U35a5ixBI7vEOSHeFQcbdOY FGDzeCGlJteVGJclePrcQ6hOwI16FJTu4x5UEBpSI1CeibKBqVddUWOC Gr1od28i4UTsifloURwinfm0TdLGdbdK6E4egQ5MdbW1B+Zhfp24IVpy 0zo=
;; Received 693 bytes from 192.31.80.30#53(d.gtld-servers.net) in 3330 ms

baidu.com. 600 IN A 123.125.114.144
baidu.com. 600 IN A 180.149.132.47
baidu.com. 600 IN A 220.181.57.217
baidu.com. 600 IN A 111.13.101.208
baidu.com. 86400 IN NS ns4.baidu.com.
baidu.com. 86400 IN NS dns.baidu.com.
baidu.com. 86400 IN NS ns2.baidu.com.
baidu.com. 86400 IN NS ns3.baidu.com.
baidu.com. 86400 IN NS ns7.baidu.com.
;; Received 272 bytes from 119.75.219.82#53(ns7.baidu.com) in 463 ms

从这个结果可以看出:到192.168.1.1(我的本地网关)
到 j.root-servers.net
到d.gtld-servers.net
到ns7.baidu.com
然后再到 220.181.57.217 (baidu.com的ip之一)

为何没有这样走:
到192.168.1.1(我的本地网关)
直接到 220.181.57.217 (baidu.com的ip之一)

我的/etc/hosts里面已经做了设置??

不理解这种行为。
头像
vickycq
帖子: 4507
注册时间: 2011-03-20 13:12
系统: Debian
来自: 山东省寿光县
联系:

Re: 搞不懂这个dig结果

#2

帖子 vickycq » 2015-12-20 16:04

我的/etc/hosts里面已经做了设置??
不理解这种行为。
man dig 写了: Unless it is told to query a specific name server, dig will try each of the
servers listed in /etc/resolv.conf. If no usable server addresses are
found, dig will send the query to the local host.

If no server argument is provided, dig consults /etc/resolv.conf; if an
address is found there, it queries the name server at that address. If
either of the -4 or -6 options are in use, then only addresses for the
corresponding transport will be tried. If no usable addresses are
found, dig will send the query to the local host.
The reply from the
name server that responds is displayed.
参考
http://serverfault.com/a/360171
http://linux.die.net/man/1/dig
http://unix.stackexchange.com/questions ... le-entries
http://serverfault.com/questions/498500 ... -etc-hosts
Debian 中文论坛 - forums.debiancn.org
欢迎所有 Debian GNU/Linux 用户
回复