In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to use the dig command in the Linux system". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to use the dig command in the Linux system".
Grammar
Dig [@ server] [- b address] [- c class] [- f filename] [- k filename] [- n] [- p port#] [- t type] [- x addr] [- y name:key] [name] [type] [class] [queryopt...]
Dig [- h]
Dig [global-queryopt...] [query...]
Description
The dig (Domain Information Searcher) command is a flexible tool for questioning DNS domain name servers. He performs a DNS search that displays the reply returned from the requested domain name server. Most DNS administrators use dig as a troubleshooting tool for DNS problems because of its flexibility, ease of use, and clear output. Although dig typically uses command-line parameters, he can also read search requests from documents in batch mode. Unlike previous versions, the BIND9 implementation of dig allows multiple queries to be issued from the command line. Unless told to request a specific domain name server, dig will try any of the servers listed in / etc/resolv.conf. When no command line arguments or options are specified, dig executes a NS query on "." (root).
Mark
-b address configures the source IP address of the address to be asked. This must be a legal address on the host network interface.
The-c class default query class (IN for internet) is reset by the option-c. Class can be any legal class, such as the HS class that queries Hesiod records or the CH class that queries CHAOSNET records.
-f filename makes dig run in batch mode, which is processed by reading a series of search requests from the document filename. The document contains many queries; one per line. Each item in the document should be organized in the same way as a query on dig using a command line interface.
-h when using the option-h, a short summary of command line arguments and options is displayed.
-k filename to sign the DNS query sent by dig along with the response to their use of transaction signature (TSIG), specify the TSIG key document with the option-k.
-n by default, search for IPv6 addresses using binary labels defined by the IP6.ARPA domain and RFC2874. To use the earlier RFC1886 method that uses the IP6.INT domain and the nibble tag, specify the option-n (nibble).
-p port# if you need to query a non-standard port number, use the option-p. Port# is the port number on which dig will send its query, rather than the standard DNS port number 53. This option can be used to test domain name servers that have been configured to listen for queries on non-standard port numbers.
-t type configure the query type as type. Can be any valid query type supported by BIND9. The default query type is A unless the-x option is provided to indicate a reverse query. A zone transfer can be requested through the type of the specified AXFR. When incremental area transfer (IXFR) is required, type is configured as ixfr=N. The incremental area transfer will contain the changes made to the region since the sequence number in the region's SOA record was changed to N.
The-x addr inverse query (mapping addresses to names) can be simplified with the-x option. Addr is an IPv4 address bounded by a decimal point or an IPv6 address bounded by a colon. When using this option, there is no need to provide name, class, and type parameters. Dig automatically runs domain name queries similar to 11.12.13.10.in-addr.arpa, and configures the query type and class to PTR and IN, respectively.
-y name:key you can specify the TSIG key through the-y option on the command line; name is the name of the TSIG password and key is the actual password. The password is a 64-bit encrypted string, usually generated by dnssec-keygen (8). Care should be taken when using the option-y on a multi-user system, as the password may be visible in the output of ps (1) or in the history document of shell. When using both dig and TSCG authentication, the name server being queried needs to know the password and decoding rules. In BIND, this is done by providing the correct password and server declaration in named.conf.
Parameters.
Global-queryopt... Global query options (see multiple queries).
Query query options (see query options).
Query options
Dig provides the query option number, which affects the search method and the display of results. Some configure or reset flag bits in the query request header, some determine which reply messages are displayed, and others determine timeouts and retry strategies. Each query option is identified by a keyword with a prefix (+). Some keywords configure or reset an option. Usually the prefix is the string no that finds the meaning of the inverse keyword. Other keywords assign values for each option, such as the timeout interval. Their format is like + keyword=value. The query options are:
+ [no] tcp
Use [do not use] TCP when querying domain name servers. The default behavior is to use UDP and use TCP connections unless it is an AXFR or IXFR request.
+ [no] vc
Use [do not use] TCP when querying name servers. The alternate syntax for + [no] tcp provides backward compatibility. Vc stands for virtual circuit.
+ [no] ignore
Ignore interrupts in the UDP response instead of retrying with TCP. Run TCP by default and try again.
+ domain=somename
Setting a search list that contains a single domain somename seems to be specified by the domain directive in / etc/resolv.conf, and search list processing is enabled, as if given the + search option.
+ [no] search
Use [do not use] search lists or search lists defined by domain directives (if any) in resolv.conf. Search lists are not used by default.
+ [no] defname
It is not recommended as a synonym for + [no] search.
+ [no] aaonly
This option does nothing. It is used to provide compatibility with older versions of dig that are configured with unimplemented parser flags.
+ [no] adflag
Configure [do not configure] the AD (real data) bit in the query. Now the AD bit only has a standard meaning in the response, not in the query, but this performance can be configured in the query for integrity.
+ [no] cdflag
Configure the [do not configure] CD bit in the query. He asks the server not to run the DNSSEC validity of the response information.
+ [no] recursive
Transform the RD (need recursion) bit configuration in the query. This bit is configured by default, which means that dig normally sends recursive queries. Recursion is automatically disabled when the query option + nssearch or + trace is used.
+ [no] nssearch
When this option is configured, dig attempts to find the authoritative domain name server of the network segment containing the name to be searched, and displays the SOA record of each domain name server in the network segment.
+ [no] trace
Convert to the name to be queried the agent path trace starting from the root name server. Tracing is not used by default. Once tracing is enabled, dig uses an iterative query to resolve the name of the query to be queried. He will display responses from each server that uses the parsing query, as referenced from the root server.
+ [no] cmd
Sets the initial comment that appears in the output indicating the version of dig and the query options it uses. Comments are displayed by default.
+ [no] short
Provide a brief reply. The default value is to display the reply message in a lengthy format.
+ [no] identify
When the + short option is enabled, the IP address and port number provided for the answer is displayed [or not]. If the request is answered in a short format, the source address and port number of the server providing the answer are not displayed by default.
+ [no] comments
Convert the display of comment lines in the output. The default value is to display comments.
+ [no] stats
The query option is set to display statistics: the size of the response while the query is in progress, and so on. Query statistics are displayed by default.
+ [no] qr
Displays [does not show] the query request sent. It is not displayed by default.
+ [no] question
When the reply is returned, the question part of the query request is displayed. The problem section is displayed by default as a comment.
+ [no] answer
Displays [does not show] the answer portion of the reply. Displays by default.
+ [no] authority
Show [do not show] the permissions section of the reply. Displays by default.
+ [no] additional
Show [do not show] additional parts of the reply. Displays by default.
+ [no] all
Configure or clear any display flags.
+ time=T
Configure the timeout for the query to be T seconds. The default is 5 seconds. If T is configured to a number less than 1, 1 second is used as the query timeout.
+ tries=A
Configure the number of retries to send UDP query requests to the server as A, instead of the default of 3. If An is less than or equal to 0, 1 is used as the number of retries.
+ ndots=D
For full consideration, the configuration must appear in the number of points in the name D. The default value is defined using the ndots statement in / etc/resolv.conf, or 1, if there is no ndots statement. Names with fewer points are interpreted as relative names and searched through the domain directive in the search list or in the document / etc/resolv.conf.
+ bufsize=B
Configure the UDP message buffer size that uses EDNS0 to be B bytes. The maximum and minimum values of the buffer are 65535 and 0, respectively. Values that are outside this range are automatically rounded to the nearest valid value.
+ [no] multiline
Displays SOA-like records in a detailed, multiline format, with readable comments. The default value is to display one record per single line so that the computer can parse the output of the dig.
Multiple queries
Dig's BIND9 supports specifying multiple queries on the command line (an additional feature that supports the-f batch document option). Each query can use its own flag bits, options, and query options.
In this case, in the command-line syntax described above, each query argument represents an individual query. Each item consists of any standard options and flags, the name of the query to be queried, the optional query type and class, along with any query options that apply to the query.
You can also use a global collection of query options that are valid for any query. The global query option must precede the tuple of the first name, class, type, option, flag, and query option on the command line. Any global query options (except the + [no] cmd option) can be reset by the query special options below. For example:
Dig + qr www.isc.org any-x 127.0.0.1 isc.org ns + noqr shows how dig makes three queries from the command line: an arbitrary query for www.isc.org, a reverse query for 127.0.0.1, and a NS record query for isc.org. The global query option of + qr is applied so that dig displays the initial query for each query. The last query has a local query option + noqr, which means that dig does not display the initial query when searching for isc.org 's NS records.
Example:
A, the easiest way
The code is as follows:
[root@rudder ~] # dig baidu.com
B, find the A record of yahoo.com
The code is as follows:
[root@rudder] # dig yahoo.com A + noall + answer
C, find the list of yahoo.com MX records
The code is as follows:
[root@rudder ~] # dig yahoo.com MX + noall + answer
D, find the authoritative DNS of yahoo.com
The code is as follows:
[root@rudder ~] # dig yahoo.com NS + noall + answer
E, query all the records above
The code is as follows:
[root@rudder ~] # dig yahoo.com ANY + noall + answer
F, in the current case where IPv4 and IPV6 are mixed, you can also use the option of AAAA to query the host's IPv6 AAAA record.
The code is as follows:
[root@rudder ~] # dig www.baidu.com AAAA + short
G, for quick answer, + short
The code is as follows:
[root@rudder ~] # dig www.baidu.com + short
The h _ multiline _ multiline option gets the SOA record of the lengthy humanized annotated DSN in multi-line mode, and in general, the information obtained with the + multiline option can display a lot, just like the BIND configuration file.
The code is as follows:
[root@rudder] # dig + nocmd baidu.com any + multiline + noall + answer
;; Truncated, retrying in TCP mode.
Baidu.com. 7200 IN SOA dns.baidu.com. Sa.baidu.com. (
2012111640; serial
300; refresh (5 minutes)
300; retry (5 minutes)
2592000; expire (4 weeks 2 days)
7200; minimum (2 hours)
)
Baidu.com. 7200 IN TXT "v=spf1 ip4:220.181.50.0/24 ip4:220.181.18.241 ip4:61.208.132.13 ip4:220.181.27.29 ip4:202.108.22.171 ip4:220.181.5.0/24 ip4:123.125.66.0/24 ip4:61.135.168.0/24 ip4:115.239.212.0/24 ip4:58.217.202.0/24 ip4:61.135.162.0/23 ip4:63.217.157.86 a mx ptr ~ all"
Baidu.com. 7200 IN MX 20 mx50.baidu.com.
Baidu.com. 7200 IN MX 10 mx.mailcdn.baidu.com.
Baidu.com. 7200 IN MX 20 mx1.baidu.com.
Baidu.com. 7200 IN MX 20 jpmx.baidu.com.
Baidu.com. 600 IN A 220.181.111.86
Baidu.com. 600 IN A 123.125.114.144
Baidu.com. 600 IN A 220.181.111.85
Baidu.com. 21600 IN NS ns2.baidu.com.
Baidu.com. 21600 IN NS ns4.baidu.com.
Baidu.com. 21600 IN NS ns3.baidu.com.
Baidu.com. 21600 IN NS dns.baidu.com.
I, reverse parsing using-x query
The code is as follows:
[root@rudder] # dig-x 220.181.111.86
J, query a different naming server
The code is as follows:
[root@rudder ~] # dig @ ns1.google.com www.google.com
K, tracking the query path of dig
The code is as follows:
[root@rudder ~] # dig baidu.com + trace
L, get the SOA record
The code is as follows:
[root@rudder ~] # dig baidu.com + nssearch
M, interpreting the TTL value
The code is as follows:
[root@rudder ~] # dig + nocmd gmail.com MX + noall + answer
N, use @ to specify the server to use-p to specify the non-standard port to use-t to specify the query type
The code is as follows:
[root@rudder] # dig sohu.com @ 202.102.134.68-p 53-t MX
Thank you for your reading, the above is the content of "how to use the dig command in the Linux system". After the study of this article, I believe you have a deeper understanding of how to use the dig command in the Linux system. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.