Dig Query A record/MX/TXT


1. Common DNS record types

1.1 A record (default)

$ dig nonabyte.com

; <<>> DiG 9.10.6 <<>> nonabyte.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 48959
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;nonabyte.com.          IN  A

;; ANSWER SECTION:
nonabyte.com.       273 IN  A   43.128.0.111

;; Query time: 80 msec
;; SERVER: 192.168.31.1#53(192.168.31.1)
;; WHEN: Sun Mar 21 20:34:11 CST 2021
;; MSG SIZE  rcvd: 57

1.2 MX(mail exchange)

$ dig nonabyte.com mx

; <<>> DiG 9.10.6 <<>> nonabyte.com mx
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 4641
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 2, ADDITIONAL: 6

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;nonabyte.com.          IN  MX

;; ANSWER SECTION:
nonabyte.com.       3600    IN  MX  0 smtp.asia.secureserver.net.
nonabyte.com.       3600    IN  MX  10 mailstore1.asia.secureserver.net.

;; AUTHORITY SECTION:
nonabyte.com.       3600    IN  NS  ns08.domaincontrol.com.
nonabyte.com.       3600    IN  NS  ns07.domaincontrol.com.

;; ADDITIONAL SECTION:
mailstore1.asia.secureserver.net. 3265 IN A 182.50.144.67
ns08.domaincontrol.com. 171653  IN  A   173.201.71.4
ns07.domaincontrol.com. 172440  IN  A   97.74.103.4
ns08.domaincontrol.com. 161262  IN  AAAA    2603:5:2270::4
ns07.domaincontrol.com. 161204  IN  AAAA    2603:5:2170::4

;; Query time: 2167 msec
;; SERVER: 192.168.31.1#53(192.168.31.1)
;; WHEN: Sun Mar 21 20:35:24 CST 2021
;; MSG SIZE  rcvd: 266```

> The record of querying MX is

> ;; ANSWER SECTION:
> nonabyte.com.     3600    IN  MX  0 smtp.asia.secureserver.net.
> nonabyte.com.     3600    IN  MX  10 mailstore1.asia.secureserver.net.
Of course, you can query it in a shorter way.



```bash
$ dig +nocmd nonabyte.com mx +noall +answer
nonabyte.com.       3519    IN  MX  0 smtp.asia.secureserver.net.
nonabyte.com.       3519    IN  MX  10 mailstore1.asia.secureserver.net.

1.3 TXT

To verify the ownership of a domain name, DNS is often used to parse TXT records, such as when applying for SSL certificate or Google or Baidu webmaster authentication.

$ dig +nocmd nonabyte.com txt +noall +answer
nonabyte.com.       600 IN  TXT "google-site-verification=-yQ17uMOlK-wdRz0bgS-32Nat2loTzq9uR2Bj9OLdI8"

1.4 CNAME

$ dig cloud.tencent.com CNAME

; <<>> DiG 9.9.4-RedHat-9.9.4-61.el7_5.1 <<>> cloud.tencent.com CNAME
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 3408
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;cloud.tencent.com.             IN      CNAME

;; ANSWER SECTION:
cloud.tencent.com.      2574    IN      CNAME   cloud.tencent-cloud.com.

;; Query time: 0 msec
;; SERVER: 183.60.83.19#53(183.60.83.19)
;; WHEN: Fri Jul 26 11:18:27 CST 2019
;; MSG SIZE  rcvd: 80

2. Other queries.

2.1 reverse query.

If you query a domain name through IP, you will generally convert the IP of the mail server into a domain name, thus reducing the possibility of being treated as spam.

$ dig -x 114.114.114.114 +short
public1.114dns.com.

reference