There is no dig command under ubuntu10.10, but there is this command under debian6
I want to install apt-get under ubuntu, but I don’t find the dig package
After searching, I found that the correct installation is to install dnsutils
apt-get install dnsutils
PS: Redhat series are installed like this
yum install bind-utils
See how the dig command can replace nslookup most of the time
root@www:~# dig sina.com
;<<>> DiG 9.7.1-P2 <<>> sina.com
;; global options:+cmd
;; Got answer:;;->>HEADER<<- opcode: QUERY, status: NOERROR, id:58809;; flags: qr rd ra; QUERY:1, ANSWER:1, AUTHORITY:5, ADDITIONAL:2;; QUESTION SECTION:;sina.com. IN A
;; ANSWER SECTION:
sina.com.60 IN A 12.130.132.30;; AUTHORITY SECTION:
sina.com.600 IN NS ns3.sina.com.cn.
sina.com.600 IN NS ns1.sina.com.
sina.com.600 IN NS ns2.sina.com.cn.
sina.com.600 IN NS ns2.sina.com.
sina.com.600 IN NS ns1.sina.com.cn.;; ADDITIONAL SECTION:
ns1.sina.com.60 IN A 114.134.80.144
ns2.sina.com.60 IN A 114.134.80.145;; Query time:255 msec
;; SERVER:208.87.241.170#53(208.87.241.170);; WHEN: Thu Nov 322:18:192011;; MSG SIZE rcvd:175
Concise use, only output A record (it is easy to get the ip address when writing the script)
dig jpuyy.com +short
Only output mx records, easy to use
dig mx jpuyy.com +short
Only output NS records
dig ns jpuyy.com
Query SOA (Start of Autority) and return to the main DNS server
dig soa jpuyy.com
Specify dns, for example query jpuyy.com records in 8.8.8.8
dig +short @8.8.8.8 jpuyy.com
Most of the time, the bottom of dig shows the query time and DNS server, time, and data size. The DNS timeout time is 30 seconds, and the query time is very useful for troubleshooting DNS problems.
;; Query time:48 msec
;; SERVER:10.202.72.118#53(10.202.72.118);; WHEN: Sun Oct 1221:41:472014;; MSG SIZE rcvd:225
DNS resolution is recursive resolution, then you can use dig to add the +trace parameter, it will display a complete, non-cached, recursive query, and display a complete trace record.
It can be found that the local DNS (10.202.72.118) returned a list of root servers, a root server (199.7.91.13) found the record of com., and one of the com. found jpuyy.com and returned the NS record. A record was found in NS.
dig jpuyy.com +trace
;<<>> DiG 9.8.2rc1-RedHat-9.8.2-0.23.rc1.el6_5.1<<>> jpuyy.com +trace
;; global options:+cmd
.493573 IN NS i.root-servers.net..493573 IN NS e.root-servers.net..493573 IN NS k.root-servers.net..493573 IN NS c.root-servers.net..493573 IN NS f.root-servers.net..493573 IN NS d.root-servers.net..493573 IN NS m.root-servers.net..493573 IN NS j.root-servers.net..493573 IN NS g.root-servers.net..493573 IN NS b.root-servers.net..493573 IN NS h.root-servers.net..493573 IN NS a.root-servers.net..493573 IN NS l.root-servers.net.;; Received 496 bytes from10.202.72.118#53(10.202.72.118)in1 ms
com.172800 IN NS b.gtld-servers.net.
com.172800 IN NS i.gtld-servers.net.
com.172800 IN NS f.gtld-servers.net.
com.172800 IN NS m.gtld-servers.net.
com.172800 IN NS l.gtld-servers.net.
com.172800 IN NS e.gtld-servers.net.
com.172800 IN NS k.gtld-servers.net.
com.172800 IN NS g.gtld-servers.net.
com.172800 IN NS a.gtld-servers.net.
com.172800 IN NS j.gtld-servers.net.
com.172800 IN NS d.gtld-servers.net.
com.172800 IN NS h.gtld-servers.net.
com.172800 IN NS c.gtld-servers.net.;; Received 487 bytes from199.7.91.13#53(199.7.91.13)in162 ms
jpuyy.com.172800 IN NS f1g1ns1.dnspod.net.
jpuyy.com.172800 IN NS f1g1ns2.dnspod.net.;; Received 209 bytes from192.5.6.30#53(192.5.6.30)in298 ms
jpuyy.com.600 IN A 114.215.158.48;; Received 43 bytes from112.90.143.29#53(112.90.143.29)in38 ms
The server is often two-wire or three-wire. If there is smart resolution, you need to test to request dns from a certain ip, and add the -b parameter
Recommended Posts