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