Difference between revisions of "Dig"

From Linuxintro
imported>ThorstenStaerk
imported>ThorstenStaerk
Line 25: Line 25:
 
  dig <abbr title="Specific DNS server">@dnsserver</abbr> <abbr title="For example linuxintro.org">domain</abbr> <abbr title="Can be ANY, A, MX, SIG, etc.. By default it is A.">type</abbr>
 
  dig <abbr title="Specific DNS server">@dnsserver</abbr> <abbr title="For example linuxintro.org">domain</abbr> <abbr title="Can be ANY, A, MX, SIG, etc.. By default it is A.">type</abbr>
 
for example
 
for example
 +
* query the 192.168.0.1 for the IP address of the hostname bartholomeus
 
  dig @192.168.0.1 bartholomeus
 
  dig @192.168.0.1 bartholomeus
 +
* query for the mail record (MX) of staerk.de
 +
<pre>
 +
root@mail:~# dig staerk.de MX
 +
 +
; <<>> DiG 9.9.5-3ubuntu0.5-Ubuntu <<>> staerk.de MX
 +
;; global options: +cmd
 +
;; Got answer:
 +
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 55597
 +
;; flags: qr rd ra; QUERY: 1, ANSWER: 5, AUTHORITY: 2, ADDITIONAL: 6
 +
 +
;; OPT PSEUDOSECTION:
 +
; EDNS: version: 0, flags:; udp: 1480
 +
;; QUESTION SECTION:
 +
;staerk.de.                    IN      MX
 +
 +
;; ANSWER SECTION:
 +
staerk.de.              3536    IN      MX      1 aspmx.l.google.com.staerk.de.
 +
staerk.de.              3536    IN      MX      5 alt2.aspmx.l.google.com.staerk.de.
 +
staerk.de.              3536    IN      MX      5 alt1.aspmx.l.google.com.staerk.de.
 +
staerk.de.              3536    IN      MX      10 alt4.aspmx.l.google.com.staerk.de.
 +
staerk.de.              3536    IN      MX      10 alt3.aspmx.l.google.com.staerk.de.
 +
</pre>
  
 
= See also =
 
= See also =
 
* [[host]]
 
* [[host]]
 
* [http://linux.die.net/man/1/dig dig's man page]
 
* [http://linux.die.net/man/1/dig dig's man page]

Revision as of 10:54, 14 June 2019

The command dig allows you to query a name server for IP addresses like this:

# dig www.linuxintro.org

; <<>> DiG 9.7.3-P1 <<>> www.linuxintro.org
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 884
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;www.linuxintro.org.            IN      A 

;; ANSWER SECTION:
www.linuxintro.org.     14400   IN      A       92.51.132.237

;; Query time: 67 msec
;; SERVER: 192.168.0.1#53(192.168.0.1)
;; WHEN: Sat Jul  2 14:34:22 2011
;; MSG SIZE  rcvd: 52

In this example we see the IP address of www.linuxintro.org is 92.51.132.237.

The syntax of a dig call is

dig @dnsserver domain type

for example

  • query the 192.168.0.1 for the IP address of the hostname bartholomeus
dig @192.168.0.1 bartholomeus
  • query for the mail record (MX) of staerk.de
root@mail:~# dig staerk.de MX

; <<>> DiG 9.9.5-3ubuntu0.5-Ubuntu <<>> staerk.de MX
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 55597
;; flags: qr rd ra; QUERY: 1, ANSWER: 5, AUTHORITY: 2, ADDITIONAL: 6

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1480
;; QUESTION SECTION:
;staerk.de.                     IN      MX

;; ANSWER SECTION:
staerk.de.              3536    IN      MX      1 aspmx.l.google.com.staerk.de.
staerk.de.              3536    IN      MX      5 alt2.aspmx.l.google.com.staerk.de.
staerk.de.              3536    IN      MX      5 alt1.aspmx.l.google.com.staerk.de.
staerk.de.              3536    IN      MX      10 alt4.aspmx.l.google.com.staerk.de.
staerk.de.              3536    IN      MX      10 alt3.aspmx.l.google.com.staerk.de.

See also