dig command snippets

Command snippets for dig.

Query A Records

Add A in the [q-type] parameter to query A records. The A records show the IPv4 address of the domain:

dig google.com A

It shows as:

C: \Users \asus>dig google.com A

; <<>> DiG 9.16.33 <<>> google.com A
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 31114
;; flags: qr rd ra; QUERY: 1, ANSWER: 6, AUTHORITY: 0, ADDITIONAL: 1

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

;; ANSWER SECTION:
google.com.     1770    IN  A   142.250.189.14

;; Query time: 191 msec
;; SERVER: 10.99.0.1#53(10.99.0.1)
;; WHEN: Sun Oct 23 12:06:27 SE Asia Standard Time 2022
;; MSG SIZE revd: 55

Dig command for Google domain with A records query

Query MX Records

Add MX in the [q-type] parameter to query MX (Mail exchange) records:

dig google.com MX

It shows as:

C: \Users \asus>dig google.com MX

; <<>> DiG 9.16.33 <<>> google.com MX
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 45681
;; flags: qr rd ra; QUERY: 1, ANSWER: 6, AUTHORITY: 0, ADDITIONAL: 1

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

;; ANSWER SECTION:
google.com.     3600    IN  MX      19 smtp.google.com

;; Query time: 200 msec
;; SERVER: 10.99.0.1#53(10.99.0.1)
;; WHEN: Sun Oct 23 12:10:35 SE Asia Standard Time 2022
;; MSG SIZE revd: 60

Dig command for Google domain with MX records query

Query SOA Records

Add SOA in the [q-type] parameter to query SOA (Start of authority) records:

dig google.com SOA

It shows as:

C: \Users \asus>dig google.com SOA

; <<>> DiG 9.16.33 <<>> google.com SOA
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 59084
;; flags: qr rd ra; QUERY: 1, ANSWER: 6, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
;; QUESTION SECTION:
;google.com.            IN  SOA

;; ANSWER SECTION:
google.com.     1227    IN  SOA     ns1.google.com. dns-admin.google.com. 483002479 900 900 1800 60

;; Query time: 200 msec
;; SERVER: 10.99.0.1#53(10.99.0.1)
;; WHEN: Sun Oct 23 12:10:56 SE Asia Standard Time 2022
;; MSG SIZE revd: 89

Dig command for Google domain with SOA records query

Query TTL Records

Add TTL in the [q-type] parameter to query TTL (Time to live) records. The TTL records show how long each record is valid and how long it takes for the record updates to reach your device.

dig google.com TTL

It shows as:

C: \Users \asus>dig google.com TTL

; <<>> DiG 9.16.33 <<>> google.com TTL
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 39922
;; flags: qr rd ra; QUERY: 1, ANSWER: 6, AUTHORITY: 0, ADDITIONAL: 1

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

;; ANSWER SECTION:
google.com.     1685    IN  A   142.250.189.14

;; Query time: 194 msec
;; SERVER: 10.99.0.1#53(10.99.0.1)
;; WHEN: Sun Oct 23 12:11:38 SE Asia Standard Time 2022
;; MSG SIZE revd: 55

;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 17495
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1

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

;; AUTHORITY SECTION:
.           833 IN  SOA a.root-servers.net. nstld.verisign-grs.com. 2022102201 1800 900 604800 86400

;; Query time: 187 msec
;; SERVER: 192.168.0.1#53(192.168.0.1)
;; WHEN: Sat Oct 23 12:11:38 SE Asia Standard Time 2022
;; MSG SIZE  rcvd: 107

Dig command for Google domain with TTL value information

Trace option

Add +trace in the {q-opt} parameter to add the trace option. The +trace option traces the delegation path from the root name servers for the domain you're looking up.

dig google.com +trace

The result is:

C: \Users \asus>dig example.com +trace

; <<>> DiG 9.16.33 <<>> example.com +trace
;; global options: +cmd
.           2819    IN  NS      c.root-servers.net.
.           2819    IN  NS      b.root-servers.net.
.           2819    IN  NS      j.root-servers.net.
.           2819    IN  NS      k.root-servers.net.
.           2819    IN  NS      g.root-servers.net.
.           2819    IN  NS      m.root-servers.net.
.           2819    IN  NS      f.root-servers.net.
.           2819    IN  NS      e.root-servers.net.
.           2819    IN  NS      h.root-servers.net.
.           2819    IN  NS      l.root-servers.net.
.           2819    IN  NS      i.root-servers.net.
.           2819    IN  NS      a.root-servers.net.
.           2819    IN  NS      d.root-servers.net.
.           2819    IN  RRSIG   NS 8 0 518400 20221104050000 20221022040000 18733 . oR+P6a50uAtecqWN
r9NNG5U×5SRBcVRDiS4Lwh1wmgYdLq7dGTIDX6Z 29rP+GPIJhkHXXFOf1ZZUPcSHbRez/ybBxrVMP5ewTrPIfuPnhcR4FoC PdzYmdAlaTOZi+u15CLe rObYHMaSvcIg2hiXzGIhXDTNzbxKo9yt485m Xw4ULUqNcsDy2fSmB6tNS4u2tUng+ /OALcdUcwc6EJ6Ad601 iL9oXVZg evgoMJ3D78w8FDbs+idPN3q qOHRakn/Nkp04ARs7kwr/tCGokNS+oiaJ+R6VPMEJF+8bCWK1cWHTA/sJ76L90rrYdBRMII40yF/eyWA25k0vnw4/ZCDnw==
;; Received 525 bytes from 10.99.0.1#53(10.99.0.1) in 193 m

dig command with trace option for Google domain

ANY option

Add ANY in the [q-type] parameter to query any records. The ANY option will show any valid query type:

dig google.com ANY

It shows as:

C: \Users \asus>dig google.com ANY

; <<>> DiG 9.16.33 <<>> google.com ANY
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 16391
;; flags: qr rd ra; QUERY: 1, ANSWER: 6, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
;; QUESTION SECTION:
;google.com.            IN  ANY

;; ANSWER SECTION:
google.com.     1995    IN  A   142.250.189.14
google.com.     1995    IN  MX  10 smtp.google.com
google.com.     1495    IN  SOA ns1.google.com. dns-admin.google.com. 483002479 900 900 1800 60
google.com.     50236   IN  NS  ns1.google.com.
google.com.     50236   IN  NS  ns2.google.com.
google.com.     50236   IN  NS  ns3.google.com.
google.com.     50236   IN  NS  ns4.google.com.

;; Query time: 197 msec
;; SERVER: 10.99.0.1#53(10.99.0.1)
;; WHEN: Sun Oct 23 12:12:55 SE Asia Standard Time 2022
;; MSG SIZE revd: 194

dig command with any option for Google domain