LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 12-20-2015, 01:21 AM   #1
luofeiyu
Member
 
Registered: Aug 2015
Posts: 237

Rep: Reputation: Disabled
Don't understand the action of the dig command


I have add a line in my /etc/hosts file on the local pc.

220.181.57.217 baidu.com


Now reboot my pc,and input dig command in the console.

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

We can get the conclusion that : to 192.168.1.1(my net gateway on local net)
to j.root-servers.net
to d.gtld-servers.net
to ns7.baidu.com
to 220.181.57.217 (one ip of many baidu.com's)

why the path is not :
to 192.168.1.1(my net gateway on local net)
directly to 220.181.57.217

I have set /etc/hosts `220.181.57.217 baidu.com`.
 
Old 12-20-2015, 03:42 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
why the path is not :
to 192.168.1.1(my net gateway on local net)
directly to 220.181.57.217

I have set /etc/hosts `220.181.57.217 baidu.com`.
dig is a dns testing tool, so it uses exclusively nameservers to resolve a domain
Other tools/commands like ping are first using the entries in /etc/hosts and then dns lookups
You can use "127.0.0.1 baidu.com" in /etc/hosts and then ping baidu.com to see what happens

Regards
 
1 members found this post helpful.
Old 12-20-2015, 09:36 AM   #3
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,776

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
And even if you have a local nameserver/forwarder like dnsmasq which consults /etc/hosts, the "+trace" option to dig tells it to start from the root servers and report each step along the way. That's never going to look at what you've done locally (unless you happen to be the registered nameserver for the domain, of course).

Last edited by rknichols; 12-20-2015 at 09:38 AM.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Don't understand the meaning of a pair of braces in xargs command line sisrnb Linux - General 7 12-23-2013 04:36 AM
I don't understand why log timestamps are UTC but date command is local time Rogue45 Linux - Newbie 5 07-19-2013 03:39 PM
I don't understand the "NICE" command extendedping Linux - Newbie 3 02-02-2009 01:20 AM
System under attack via FTP, trying to understand the intended action mikeyt_333 Linux - Security 2 05-05-2006 09:44 AM
don't understand r* command security weronpc Linux - Security 2 12-09-2003 12:53 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 05:46 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration