I believe that the use of Nslookup students must be more than the use of dig students, so it is necessary to take some time to introduce you to dig.
Dig, and Nslookup functions are similar, are DNS query tools.
Dig, in fact, is an abbreviation, that is, domain information Groper.
Some professional DNS administrators in the tracing of DNS issues, are happy to use the dig command, is a fancy dig set flexible, output clear, powerful features.
"The simplest dig usage"
The simplest dig usage is, of course, the direct input dig press ENTER.?
From the above output, you must have observed that when you use the dig command directly without any parameters and options, dig queries the default up-to-connect DNS server. NS record (root domain).
"Dig Add a Point"
Just enter dig directly, this time we add a "." To see what the difference between the results and just now:?
"I want to use Google-dns to check baidu.com's a record."?
From this example, everyone learns that the basic command format for dig is:?
If you set the DNSServer to be a domain name, then dig will first query the corresponding IP address through the default up-to-connect DNS server, and then set the DNSServer as the upper-connection DNS server.
If you do not set @dnsserver, then dig will use the address in/etc/resolv.conf in turn as the upper-connection DNS server.
And for QueryType, if you read my last on the nslookup command, then you should have a knowledge of querytype, you can set the A/aaaa/ptr/mx/any equivalent, the default is to query a record.
"Some common options"
The 1-c option allows you to set the protocol type (class), including in (default), CH, and HS.
2-f option , dig support to read content from a file for batch queries, this is very thoughtful and convenient. The content of the file requires one row for a query request. Let's take a practical example:?
3-4 and 62 options for setting only which one is used as the query Packet transport protocol, corresponding to IPV4 and IPV6 respectively.
The 4-t option , which is used to set the query type, is a by default, or can be set to a type such as MX, for example:?
The 5-q option , in fact, is a redundant option in itself, but it is also useful in complex dig commands. The-Q option allows you to explicitly set the domain name you want to query, which avoids confusion with many other parameters and options, improving the readability of the command, for example:?
The 6-x option is the reverse query option. You can query the mapping of IP addresses to domain names. To give an example:?
"Dig-specific query option"
Unlike just the options, dig also has a number of so-called "query Options", the use of this batch of options will affect the Dig query mode or output results information, so for this batch of options, dig requires explicit in front of the unified plus a "+" (plus), so that dig recognition will be more convenient, Commands are also more readable.
Dig a total of 42 query options, involving all aspects of DNS information, so many query options, this article will not be one by one to repeat, will only pick out the most commonly used in several key explanations.
"TCP instead of UDP"
It is well known that the interaction in the DNS query process is UDP-based. If you want to use TCP, you need this:?
"Append Domain by default"
If you look directly at the example, you should be able to understand the concept of "Default Domain", and you can understand the role of +domain=somedomain:?
"Tracking dig whole process"
Dig is a very famous query option is +trace, when using this query option, dig will be tracking from the root domain until the query to the final result, and the entire process information output.?
"Thin dig Output"
1 If you use +nocmd, you can save output dig version information.
2 with +short, only the most streamlined CNAME information and a record will be exported, and none of the others will be output. Just like this:?
3 using +nocomment, you can save the details of the output dig annotation information.
4 If you use +nostat, the final statistic will not be output. When +nocmd, +nocomment and +nostat are used, this is the case:?
Linux command dig command to dig out DNS secrets