Dig Linux Usage

Source: Internet
Author: User

In general, there are two options for querying domain name resolution in Linux, Nslookup or dig, and I think dig more convenient to use.
If it is under Debian, you can use the dig command as long as you install the Dnsutils package.

The most basic way to use it is

Dig www.oolec.com

That is, querying the domain name of a record, the queried DNS server will take the system configuration of the server, that is,/etc/resovle.conf.

If you want to query other types of records, such as Mx,cname,ns,ptr, just add the type to the command

Dig www.oolec.com mx
Dig www.oolec.com NS

In addition, if you are a system administrator who wants to parse a DNS server after it has been deployed, you must explicitly specify the DNS server address to be tested, for example

Dig @202.106.0.20 www.oolec.com A

By default, dig will use the UDP protocol to query, if you want to use TCP, you can add the +TCP parameter

Dig www.oolec.com a +tcp

Another important feature is the +trace parameter, which will display the process of querying from the root domain after using this parameter

Dig www.oolec.com a +trace

For example, to the site domain name www.linuxers.cn A trace query can see the root domain. The top-level domain. CN, as well as the address of the domain authoritative server for linuxers.cn and their respective return results, are useful for tracking problems in DNS resolution.

Leconte@localhost: ~$ dig www.linuxers.cn a +trace

;<<>> DiG 9.5.1-P3<<>> www.linuxers.cn a +trace
;; Global Options:printcmd
.215857 in NS e.root-servers.net.
.215857 in NS b.root-servers.net.
.215857 in NS j.root-servers.net.
.215857 in NS k.root-servers.net.
.215857 in NS l.root-servers.net.
.215857 in NS f.root-servers.net.
.215857 in NS g.root-servers.net.
.215857 in NS i.root-servers.net.
.215857 in NS m.root-servers.net.
.215857 in NS a.root-servers.net.
.215857 in NS c.root-servers.net.
.215857 in NS h.root-servers.net.
.215857 in NS d.root-servers.net.
;; Received228 bytes from 192.168.127.2#53 (192.168.127.2) in MS

cn.172800 in NS a.dns.cn.
cn.172800 in NS b.dns.cn.
cn.172800 in NS c.dns.cn.
cn.172800 in NS d.dns.cn.
cn.172800 in NS e.dns.cn.
cn.172800 in NS ns.cernet.net.
; Received 298 bytes from 199.7.83.42# (l.root-servers.net) in 496 Ms
 
linuxers.cn. 21600 in NS ns1.dnspood.net.
linuxers.cn. 21600 in NS ns2.dnspood.net.
; Received 80 bytes from 202.112.0.44# (ns.cernet.net) in Ms
 
www.linuxers.cn. 600 in A 218.240.42.72
; Received 49 bytes from 222.186.26.115 #53 (ns2.dnspood.net) in 1132 Ms

Use under Dig Linux

Related Article

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.