Linux Dig Commands

Source: Internet
Author: User
Tags domain name server mx record

Dig (Domain information Groper), and Nslookup functions are similar, are DNS query tools

1.Dig command Format

Dig @dnsserver name QueryType

    • If you set the DNSServer to be a domain name, first use the default up-to-connect DNS server to query the corresponding IP address, 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

    • QueryType can set the A/aaaa/ptr/mx/any equivalent, the default is to query a record.

2 . Common Options

Parameter description

-C can set the protocol type (class), including in (default), CH, and HS

-F 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

-T is used to set the query type, which is a by default, and can also be set to types such as MX

The-Q-Q option allows you to explicitly set the domain name you want to query, which avoids confusion with many other parameters, options, and improves the readability of the command.

-X is the inverse query option. Can query the IP address to the Domain name Mapping relations

3, Query the case :

#dig baidu.com-t mx query Baidu's MX record

; <<>> DiG 9.8.2rc1-redhat-9.8.2-0.37.rc1.el6 <<>> baidu.com-t mx

;; Global options: +cmd

;; Got Answer:

;; ->>header<<-opcode:query, Status:noerror, id:3440

;; Flags:qr Rd RA; Query:1, Answer:4, authority:0, additional:0

;; QUESTION section:

; baidu.com. In MX

;; ANSWER section:

Baidu.com. 5 in MX mx1.baidu.com.

Baidu.com. 5 in MX jpmx.baidu.com.

Baidu.com. 5 in MX ten mx.n.shifen.com.

Baidu.com. 5 in MX mx50.baidu.com.

3. Dig-specific query options

  • +trace dig queries from the root domain until the final result is queried and the entire process information is output.

  • +nocmd can save output dig version information.

  • +short will only output the most streamlined CNAME information and a record, and none of the others will output.

  • +nocomment words, you can save the details of the output dig annotation information

  • +[no]stats This query option sets the display statistics: When the query is made, the size of the answer, and so on. The query statistics are displayed by default.

  • +[no]nssearch When this option is set, Dig attempts to locate the authoritative domain name server that contains the network segment for which the name is to be searched and displays the SOA record for each domain name server in the network segment.

  • +[no]recursive Switch the RD (requires recursive) bit setting in the query. This bit is set by default, which means that dig normally sends a recursive query. Recursion is automatically disabled when you use the query option +nssearch or +trace.

  • +[no]search uses a search list that is defined using the field pseudo-directive (if any) in the search list or resolv.conf. The search list is not used by default.

Query Case List

    • #dig +short www.baidu.com will only output Baidu's condensed CNAME information and a record

Www.a.shifen.com.

119.75.218.77

119.75.217.56

    • # dig +nocmd +nocomment +nostat www.baidu.com

; www.baidu.com. In A

Www.baidu.com. 260 in CNAME www.a.shifen.com.

Www.a.shifen.com. 244 in a 119.75.217.56

Www.a.shifen.com. 244 in a 119.75.218.77

    • #dig @223.5.5.5 www.baidu.com +trace+nocmd queries from the root domain are tracked until the final result is queried

; <<>> DiG 9.8.2rc1-redhat-9.8.2-0.37.rc1.el6 <<>> @223.5.5.5 www.baidu.com Trace +nocmd

; (1 server found)

;; Global options: +cmd

. 340255 in NS j.root-servers.net.

. 340255 in NS l.root-servers.net.

. 340255 in NS e.root-servers.net.

. 340255 in NS b.root-servers.net.

. 340255 in NS c.root-servers.net.

. 340255 in NS h.root-servers.net.

. 340255 in NS d.root-servers.net.

. 340255 in NS a.root-servers.net.

. 340255 in NS f.root-servers.net.

. 340255 in NS i.root-servers.net.

. 340255 in NS k.root-servers.net.

. 340255 in NS g.root-servers.net.

. 340255 in NS m.root-servers.net.

;; Received 228 bytes from 223.5.5.5#53 (223.5.5.5) in + MS

Com. 172800 in NS a.gtld-servers.net.

Com. 172800 in NS b.gtld-servers.net.

Com. 172800 in NS c.gtld-servers.net.

Com. 172800 in NS d.gtld-servers.net.

Com. 172800 in NS e.gtld-servers.net.

Com. 172800 in NS f.gtld-servers.net.

Com. 172800 in NS g.gtld-servers.net.

Com. 172800 in NS h.gtld-servers.net.

Com. 172800 in NS i.gtld-servers.net.

Com. 172800 in NS j.gtld-servers.net.

Com. 172800 in NS k.gtld-servers.net.

Com. 172800 in NS l.gtld-servers.net.

Com. 172800 in NS m.gtld-servers.net.

;; Received 491 bytes from 199.7.83.42#53 (199.7.83.42) in 144 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.

Linux Dig Commands

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.