dig
El comando dig (Domain Information Groper) permite realizar consultas a los servidores DNS, por lo que, al igual que los comandos host y nslookup, nos será muy útil para comprobar si el DNS está correctamente configurado en un ordenador. Permite comprobar tanto el mapeo de nombre a IP como el mapeo inverso de IP a nombre, pero sólo sirve para Internet, ya que no mira en /etc/hosts, solo utiliza /etc/resolv.conf. Además, nos da el tiempo que tarda en hacerse la traducción.
# dig www.google.es
; <<>> DiG 9.8.4-rpz2+rl005.12-P1 <<>> www.google.es
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 39967
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;www.google.es. IN A
;; ANSWER SECTION:
www.google.es. 196 IN A 173.194.45.31
www.google.es. 196 IN A 173.194.45.23
www.google.es. 196 IN A 173.194.45.24
;; Query time: 53 msec
;; SERVER: 87.216.1.65#53(87.216.1.65)
;; WHEN: Sun Nov 10 23:29:53 2013
;; MSG SIZE rcvd: 79
Se puede hacer la consulta a un servidor de nombres concreto:
# dig @8.8.8.8 www.google.es
; <<>> DiG 9.8.4-rpz2+rl005.12-P1 <<>> @8.8.8.8 www.google.es
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 2866
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;www.google.es. IN A
;; ANSWER SECTION:
www.google.es. 130 IN A 173.194.34.223
www.google.es. 130 IN A 173.194.34.215
www.google.es. 130 IN A 173.194.34.216
;; Query time: 79 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Sun Nov 10 23:34:15 2013
;; MSG SIZE rcvd: 79
Para hacer traducción inversa:
# dig -x 213.4.130.95
; <<>> DiG 9.8.4-rpz2+rl005.12-P1 <<>> -x 213.4.130.95
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 20963
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;95.130.4.213.in-addr.arpa. IN PTR
;; ANSWER SECTION:
95.130.4.213.in-addr.arpa. 82161 IN PTR www.telefonica.net.
;; Query time: 49 msec
;; SERVER: 87.216.1.65#53(87.216.1.65)
;; WHEN: Sun Nov 10 23:43:08 2013
;; MSG SIZE rcvd: 75
Para consultar sobre la información de un dominio debemos especificar la opción -t con el valor del tipo de registro, en este caso NS:
# dig -t ns rediris.es
; <<>> DiG 9.9.5-9+deb8u6-Debian <<>> -t ns rediris.es
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 21625
;; flags: qr rd ra; QUERY: 1, ANSWER: 5, AUTHORITY: 0, ADDITIONAL: 9
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;rediris.es. IN NS
;; ANSWER SECTION:
rediris.es. 6667 IN NS ns15.communitydns.net.
rediris.es. 6667 IN NS ns02.fccn.pt.
rediris.es. 6667 IN NS sun.rediris.es.
rediris.es. 6667 IN NS chico.rediris.es.
rediris.es. 6667 IN NS scsnms.switch.ch.
;; ADDITIONAL SECTION:
ns02.fccn.pt. 71095 IN A 193.136.2.228
ns02.fccn.pt. 263 IN AAAA 2001:690:a80:4001::200
sun.rediris.es. 18063 IN A 130.206.1.2
sun.rediris.es. 3500 IN AAAA 2001:720:418:caf1::2
chico.rediris.es. 13572 IN A 130.206.1.3
chico.rediris.es. 6091 IN AAAA 2001:720:418:caf1::3
scsnms.switch.ch. 81187 IN A 130.59.10.30
scsnms.switch.ch. 81187 IN A 130.59.1.30
;; Query time: 17 msec
;; SERVER: 87.216.1.65#53(87.216.1.65)
;; WHEN: Sat Apr 11 11:40:36 CEST 2016
;; MSG SIZE rcvd: 332
Da igual escribir el tipo de registro en mayúscula o en minúscula.
Para solicitar otros tipos de registros, por ejemplo SOA y MX:
# dig -t soa rediris.es
; <<>> DiG 9.9.5-9+deb8u6-Debian <<>> -t soa rediris.es
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 43326
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;rediris.es. IN SOA
;; ANSWER SECTION:
rediris.es. 7099 IN SOA sun.rediris.es. hostmaster.rediris.es. 2016040601 14400 7200 2592000 7200
;; Query time: 17 msec
;; SERVER: 87.216.1.65#53(87.216.1.65)
;; WHEN: Sat Apr 11 11:45:57 CEST 2016
;; MSG SIZE rcvd: 90
# dig -t mx rediris.es
; <<>> DiG 9.9.5-9+deb8u6-Debian <<>> -t mx rediris.es
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 60130
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;rediris.es. IN MX
;; ANSWER SECTION:
rediris.es. 7188 IN MX 10 mx02.puc.rediris.es.
rediris.es. 7188 IN MX 10 mx01.puc.rediris.es.
;; Query time: 17 msec
;; SERVER: 87.216.1.65#53(87.216.1.65)
;; WHEN: Sat Apr 11 11:45:59 CEST 2016
;; MSG SIZE rcvd: 85
Licencia: licencia de software libre GPL