Commandes Linux : dig

DIG

Installé avec le paquet dnsutils
Voir aussi : nslookup et host.

 

Préférer les commandes dans cet ordre (niveau de détails retournés)

  1. dig
  2. host
  3. nslookup

 

Afficher la version de la commande dig

dig -v

ou

apt-cache policy dnsutils

 

Requêter un enregistrement particulier de type A

dig www.opensharing.priv

ex :

# dig www.opensharing.priv

; <<>> DiG 9.9.5-9+deb8u6-Debian <<>> www.opensharing.priv
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 16352
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 2, ADDITIONAL: 3

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

;; ANSWER SECTION:
www.opensharing.priv.	86400	IN	CNAME	wp-test.opensharing.priv.
wp-test.opensharing.priv. 86400	IN	A	192.168.1.14

;; AUTHORITY SECTION:
opensharing.priv.	86400	IN	NS	dns1-test.opensharing.priv.
opensharing.priv.	86400	IN	NS	dns2-test.opensharing.priv.

;; ADDITIONAL SECTION:
dns1-test.opensharing.priv. 86400 IN	A	192.168.1.11
dns2-test.opensharing.priv. 86400 IN	A	192.168.1.12

;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Mon Jun 27 13:09:28 CEST 2016
;; MSG SIZE  rcvd: 167

 

Requêter un enregistrement particulier de type A, mais avec une réponse brève

dig www.opensharing.priv +short

ex :

# dig www.opensharing.priv +short
wp-test.opensharing.priv.
192.168.1.14

 

Requête inversée pour un enregistrement particulier de type PTR

dig -x 192.168.1.14

ex :

# dig -x 192.168.1.14

; <<>> DiG 9.9.5-9+deb8u6-Debian <<>> -x 192.168.1.14
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 43562
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 3

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;14.1.168.192.in-addr.arpa.	IN	PTR

;; ANSWER SECTION:
14.1.168.192.in-addr.arpa. 86400 IN	PTR	www.opensharing.priv.

;; AUTHORITY SECTION:
1.168.192.in-addr.arpa.	86400	IN	NS	dns1-test.opensharing.priv.
1.168.192.in-addr.arpa.	86400	IN	NS	dns2-test.opensharing.priv.

;; ADDITIONAL SECTION:
dns1-test.opensharing.priv. 86400 IN	A	192.168.1.11
dns2-test.opensharing.priv. 86400 IN	A	192.168.1.12

;; Query time: 1 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Mon Jun 27 13:11:20 CEST 2016
;; MSG SIZE  rcvd: 168

Ce qui revient à :

dig PTR 14.1.168.192.in-addr.arpa

ex :

# dig PTR 14.1.168.192.in-addr.arpa

; <<>> DiG 9.9.5-9+deb8u6-Debian <<>> PTR 14.1.168.192.in-addr.arpa
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 32782
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 3

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;14.1.168.192.in-addr.arpa.	IN	PTR

;; ANSWER SECTION:
14.1.168.192.in-addr.arpa. 86400 IN	PTR	www.opensharing.priv.

;; AUTHORITY SECTION:
1.168.192.in-addr.arpa.	86400	IN	NS	dns1-test.opensharing.priv.
1.168.192.in-addr.arpa.	86400	IN	NS	dns2-test.opensharing.priv.

;; ADDITIONAL SECTION:
dns1-test.opensharing.priv. 86400 IN	A	192.168.1.11
dns2-test.opensharing.priv. 86400 IN	A	192.168.1.12

;; Query time: 3 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Mon Jun 27 13:12:29 CEST 2016
;; MSG SIZE  rcvd: 168

 

Requêter un serveur de noms particulier

dig @dns1.opensharing.priv www.opensharing.priv
dig @192.168.1.11 www.opensharing.priv

ex :

# dig @dns1.opensharing.priv www.opensharing.priv

; <<>> DiG 9.9.5-9+deb8u6-Debian <<>> @dns1.opensharing.priv www.opensharing.priv
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 46060
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 2, ADDITIONAL: 3

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

;; ANSWER SECTION:
www.opensharing.priv.	86400	IN	CNAME	wp-test.opensharing.priv.
wp-test.opensharing.priv. 86400	IN	A	192.168.1.14

;; AUTHORITY SECTION:
opensharing.priv.	86400	IN	NS	dns1-test.opensharing.priv.
opensharing.priv.	86400	IN	NS	dns2-test.opensharing.priv.

;; ADDITIONAL SECTION:
dns1-test.opensharing.priv. 86400 IN	A	192.168.1.11
dns2-test.opensharing.priv. 86400 IN	A	192.168.1.12

;; Query time: 0 msec
;; SERVER: 192.168.1.11#53(192.168.1.11)
;; WHEN: Mon Jun 27 13:13:25 CEST 2016
;; MSG SIZE  rcvd: 167
# dig @192.168.1.11 www.opensharing.priv

; <<>> DiG 9.9.5-9+deb8u6-Debian <<>> @192.168.1.11 www.opensharing.priv
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 3896
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 2, ADDITIONAL: 3

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

;; ANSWER SECTION:
www.opensharing.priv.	86400	IN	CNAME	wp-test.opensharing.priv.
wp-test.opensharing.priv. 86400	IN	A	192.168.1.14

;; AUTHORITY SECTION:
opensharing.priv.	86400	IN	NS	dns1-test.opensharing.priv.
opensharing.priv.	86400	IN	NS	dns2-test.opensharing.priv.

;; ADDITIONAL SECTION:
dns1-test.opensharing.priv. 86400 IN	A	192.168.1.11
dns2-test.opensharing.priv. 86400 IN	A	192.168.1.12

;; Query time: 0 msec
;; SERVER: 192.168.1.11#53(192.168.1.11)
;; WHEN: Mon Jun 27 13:14:04 CEST 2016
;; MSG SIZE  rcvd: 167

 

Requêter l'enregistrement de type A d’un domaine particulier (type par défaut)

dig A opensharing.priv

ex :

# dig A opensharing.priv

; <<>> DiG 9.9.5-9+deb8u6-Debian <<>> A opensharing.priv
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 31934
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 3

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

;; ANSWER SECTION:
opensharing.priv.	86400	IN	A	192.168.1.14

;; AUTHORITY SECTION:
opensharing.priv.	86400	IN	NS	dns2-test.opensharing.priv.
opensharing.priv.	86400	IN	NS	dns1-test.opensharing.priv.

;; ADDITIONAL SECTION:
dns1-test.opensharing.priv. 86400 IN	A	192.168.1.11
dns2-test.opensharing.priv. 86400 IN	A	192.168.1.12

;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Mon Jun 27 13:15:04 CEST 2016
;; MSG SIZE  rcvd: 141

 

Requêter tous les types d'enregistrements d’un domaine

dig ANY opensharing.priv

ex :

# dig ANY opensharing.priv

; <<>> DiG 9.9.5-9+deb8u6-Debian <<>> ANY opensharing.priv
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 49042
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 6, AUTHORITY: 0, ADDITIONAL: 5

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;opensharing.priv.		IN	ANY

;; ANSWER SECTION:
opensharing.priv.	86400	IN	SOA	dns1-test.opensharing.priv. adminsys.opensharing.priv. 2016061902 21600 3600 604800 86400
opensharing.priv.	86400	IN	NS	dns1-test.opensharing.priv.
opensharing.priv.	86400	IN	NS	dns2-test.opensharing.priv.
opensharing.priv.	86400	IN	MX	10 mail1-test.opensharing.priv.
opensharing.priv.	86400	IN	MX	20 mail2-test.opensharing.priv.
opensharing.priv.	86400	IN	A	192.168.1.14

;; ADDITIONAL SECTION:
dns1-test.opensharing.priv. 86400 IN	A	192.168.1.11
dns2-test.opensharing.priv. 86400 IN	A	192.168.1.12
mail1-test.opensharing.priv. 86400 IN	A	192.168.1.15
mail2-test.opensharing.priv. 86400 IN	A	192.168.1.16

;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Mon Jun 27 13:15:47 CEST 2016
;; MSG SIZE  rcvd: 272

ou (si le transfert de zones est autorisé) :

dig AXFR opensharing.priv

ou, si une clef TSIG est requise pour le transfert de zones :

dig AXFR opensharing.priv -k /etc/bind/tsig.key

ex :

# dig AXFR opensharing.priv

; <<>> DiG 9.9.5-9+deb8u6-Debian <<>> AXFR opensharing.priv
;; global options: +cmd
opensharing.priv.	86400	IN	SOA	dns1-test.opensharing.priv. adminsys.opensharing.priv. 2016061902 21600 3600 604800 86400
opensharing.priv.	86400	IN	NS	dns1-test.opensharing.priv.
opensharing.priv.	86400	IN	NS	dns2-test.opensharing.priv.
opensharing.priv.	86400	IN	MX	10 mail1-test.opensharing.priv.
opensharing.priv.	86400	IN	MX	20 mail2-test.opensharing.priv.
opensharing.priv.	86400	IN	A	192.168.1.14
dhcp1.opensharing.priv.	86400	IN	CNAME	dns1-test.opensharing.priv.
dns1.opensharing.priv.	86400	IN	CNAME	dns1-test.opensharing.priv.
dns1-test.opensharing.priv. 86400 IN	A	192.168.1.11
dns2.opensharing.priv.	86400	IN	CNAME	dns2-test.opensharing.priv.
dns2-test.opensharing.priv. 86400 IN	A	192.168.1.12
mail1.opensharing.priv.	86400	IN	CNAME	mail1-test.opensharing.priv.
mail1-test.opensharing.priv. 86400 IN	A	192.168.1.15
mail2.opensharing.priv.	86400	IN	CNAME	mail2-test.opensharing.priv.
mail2-test.opensharing.priv. 86400 IN	A	192.168.1.16
opsi.opensharing.priv.	86400	IN	CNAME	opsi-test.opensharing.priv.
opsi-test.opensharing.priv. 86400 IN	A	192.168.1.13
wp-test.opensharing.priv. 86400	IN	A	192.168.1.14
www.opensharing.priv.	86400	IN	CNAME	wp-test.opensharing.priv.
opensharing.priv.	86400	IN	SOA	dns1-test.opensharing.priv. adminsys.opensharing.priv. 2016061902 21600 3600 604800 86400
;; Query time: 1 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Mon Jun 27 13:16:38 CEST 2016
;; XFR size: 20 records (messages 1, bytes 482)

ou :

dig ANY opensharing.priv +nocmd +multiline +noall +answer

ex :

# dig ANY opensharing.priv +nocmd +multiline +noall +answer

; <<>> DiG 9.9.5-9+deb8u6-Debian <<>> ANY opensharing.priv +nocmd +multiline +noall +answer
;; global options: +cmd
opensharing.priv.	86400 IN SOA dns1-test.opensharing.priv. adminsys.opensharing.priv. (
				2016061902 ; serial
				21600      ; refresh (6 hours)
				3600       ; retry (1 hour)
				604800     ; expire (1 week)
				86400      ; minimum (1 day)
				)
opensharing.priv.	86400 IN NS dns2-test.opensharing.priv.
opensharing.priv.	86400 IN NS dns1-test.opensharing.priv.
opensharing.priv.	86400 IN MX 20 mail2-test.opensharing.priv.
opensharing.priv.	86400 IN MX 10 mail1-test.opensharing.priv.
opensharing.priv.	86400 IN A 192.168.1.14.

 

Requêter les enregistrements de type NS d’un domaine particulier

dig NS opensharing.priv

ex :

# dig NS opensharing.priv

; <<>> DiG 9.9.5-9+deb8u6-Debian <<>> NS opensharing.priv
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 8222
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 3

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;opensharing.priv.		IN	NS

;; ANSWER SECTION:
opensharing.priv.	86400	IN	NS	dns2-test.opensharing.priv.
opensharing.priv.	86400	IN	NS	dns1-test.opensharing.priv.

;; ADDITIONAL SECTION:
dns1-test.opensharing.priv. 86400 IN	A	192.168.1.11
dns2-test.opensharing.priv. 86400 IN	A	192.168.1.12

;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Mon Jun 27 13:17:41 CEST 2016
;; MSG SIZE  rcvd: 125

 

Afficher la liste des 13 serveurs racine (A à M)

dig NS . +short

ex :

# dig NS . +short
g.root-servers.net.
c.root-servers.net.
f.root-servers.net.
m.root-servers.net.
h.root-servers.net.
l.root-servers.net.
i.root-servers.net.
a.root-servers.net.
d.root-servers.net.
k.root-servers.net.
e.root-servers.net.
b.root-servers.net.
j.root-servers.net.

 

Requêter les enregistrements de type MX (Mail eXchanger) d’un domaine particulier

dig MX opensharing.priv

ex :

# dig MX opensharing.priv

; <<>> DiG 9.9.5-9+deb8u6-Debian <<>> MX opensharing.priv
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 42216
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 2, ADDITIONAL: 5

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

;; ANSWER SECTION:
opensharing.priv.	86400	IN	MX	10 mail1-test.opensharing.priv.
opensharing.priv.	86400	IN	MX	20 mail2-test.opensharing.priv.

;; AUTHORITY SECTION:
opensharing.priv.	86400	IN	NS	dns2-test.opensharing.priv.
opensharing.priv.	86400	IN	NS	dns1-test.opensharing.priv.

;; ADDITIONAL SECTION:
mail1-test.opensharing.priv. 86400 IN	A	192.168.1.15
mail2-test.opensharing.priv. 86400 IN	A	192.168.1.16
dns1-test.opensharing.priv. 86400 IN	A	192.168.1.11
dns2-test.opensharing.priv. 86400 IN	A	192.168.1.12

;; Query time: 2 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Mon Jun 27 13:18:06 CEST 2016
;; MSG SIZE  rcvd: 211

 

Requêter l'enregistrement de type SOA d’un domaine particulier

dig SOA opensharing.priv

ex :

# dig SOA opensharing.priv

; <<>> DiG 9.9.5-9+deb8u6-Debian <<>> SOA opensharing.priv
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 34
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 3

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;opensharing.priv.		IN	SOA

;; ANSWER SECTION:
opensharing.priv.	86400	IN	SOA	dns1-test.opensharing.priv. adminsys.opensharing.priv. 2016061902 21600 3600 604800 86400

;; AUTHORITY SECTION:
opensharing.priv.	86400	IN	NS	dns2-test.opensharing.priv.
opensharing.priv.	86400	IN	NS	dns1-test.opensharing.priv.

;; ADDITIONAL SECTION:
dns1-test.opensharing.priv. 86400 IN	A	192.168.1.11
dns2-test.opensharing.priv. 86400 IN	A	192.168.1.12

;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Mon Jun 27 13:18:49 CEST 2016
;; MSG SIZE  rcvd: 170

 

Afficher les traces de résolution récursive depuis les serveurs root

dig www.opensharing.fr +trace

ex :

# dig www.opensharing.fr +trace

; <<>> DiG 9.9.5-9+deb8u6-Debian <<>> www.opensharing.fr +trace
;; global options: +cmd
.			516090	IN	NS	a.root-servers.net.
.			516090	IN	NS	b.root-servers.net.
.			516090	IN	NS	e.root-servers.net.
.			516090	IN	NS	k.root-servers.net.
.			516090	IN	NS	l.root-servers.net.
.			516090	IN	NS	c.root-servers.net.
.			516090	IN	NS	i.root-servers.net.
.			516090	IN	NS	j.root-servers.net.
.			516090	IN	NS	d.root-servers.net.
.			516090	IN	NS	h.root-servers.net.
.			516090	IN	NS	f.root-servers.net.
.			516090	IN	NS	m.root-servers.net.
.			516090	IN	NS	g.root-servers.net.
;; Received 913 bytes from 127.0.0.1#53(127.0.0.1) in 7 ms

fr.			172800	IN	NS	d.ext.nic.fr.
fr.			172800	IN	NS	d.nic.fr.
fr.			172800	IN	NS	e.ext.nic.fr.
fr.			172800	IN	NS	f.ext.nic.fr.
fr.			172800	IN	NS	g.ext.nic.fr.
;; Received 614 bytes from 199.7.83.42#53(l.root-servers.net) in 19 ms

opensharing.fr.		172800	IN	NS	dns18.ovh.net.
opensharing.fr.		172800	IN	NS	ns18.ovh.net.
;; Received 618 bytes from 193.176.144.22#53(e.ext.nic.fr) in 16 ms

www.opensharing.fr.	3600	IN	CNAME	opensharing.fr.
opensharing.fr.		3600	IN	A	213.186.33.4
;; Received 77 bytes from 213.251.188.138#53(dns18.ovh.net) in 9 ms
Fermer le menu
%d blogueurs aiment cette page :