El comando dig sirve pare realizar consultas sencillas a un servidor DNS y obtener cualquier registro que interese de un dominio. Por defecto, el comando usa los servidores predeterminados de nuestro sistema, ubicados en /etc/resolv.conf y pide los registros de tipo A.
shell> dig google.es ; <<>> DiG 9.7.3 <<>> google.es ; (1 server found) ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode:QUERY, status:NOERROR, id:11789 ;; flags:qr rd ra; QUERY:1, ANSWER:6, AUTHORITY:0, ADDITIONAL:0 ;; QUESTION SECTION: ;google.es. IN A ;; ANSWER SECTION: google.es. 300 IN A 209.85.148.104 google.es. 300 IN A 209.85.148.106 google.es. 300 IN A 209.85.148.103 google.es. 300 IN A 209.85.148.105 google.es. 300 IN A 209.85.148.99 google.es. 300 IN A 209.85.148.147 ;; Query time: 63 msec ;; SERVER: 8.8.8.8#53(8.8.8.8) ;; WHEN: Tue Oct 11 17:13:38 2011 ;; MSG SIZE rcvd: 123
Los princiaples registros que DNS maneja son:
- A, define la dirección IPv4.
- AAA, define la dirección IPv6.
- NS, define los servidores DNS.
- MX, define los servidores de correo.
- CNAME, permite definir alias de otros nombres.
- SOA, contiene información sobre el servidor DNS primario
- LOC, define la localización
shell> dig google.com MX ; <<>> DiG 9.7.3 <<>> google.com MX ; (1 server found) ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode:QUERY, status:NOERROR, id:52776 ;; flags: qr rd ra; QUERY:1, ANSWER:5, AUTHORITY:0, ADDITIONAL:0 ;; QUESTION SECTION: ;google.com. IN MX ;; ANSWER SECTION: google.com. 600 IN MX 20 alt1.aspmx.l.google.com. google.com. 600 IN MX 40 alt3.aspmx.l.google.com. google.com. 600 IN MX 50 alt4.aspmx.l.google.com. google.com. 600 IN MX 30 alt2.aspmx.l.google.com. google.com. 600 IN MX 10 aspmx.l.google.com. ;; Query time: 74 msec ;; SERVER: 8.8.8.8#53(8.8.8.8) ;; WHEN: Tue Oct 11 17:32:31 2011 ;; MSG SIZE rcvd: 136
Si lo que tenemos es una dirección IP y queremos saber todos los nombres a los que resuelve, simplemente usamos el parámetro -x de dig, consiguiendo así el registro inverso.
shell> dig -x 74.125.39.104 ; <<>> DiG 9.7.3 <<>> -x 74.125.39.104 ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode:QUERY, status:NOERROR, id:64624 ;; flags: qr rd ra; QUERY:1, ANSWER:1, AUTHORITY:4, ADDITIONAL:4 ;; QUESTION SECTION: ;104.39.125.74.in-addr.arpa. IN PTR ;; ANSWER SECTION: 104.39.125.74.in-addr.arpa. 72856 IN PTR fx-in-f104.1e100.net. ;; AUTHORITY SECTION: 125.74.in-addr.arpa. 61161 IN NS NS4.GOOGLE.COM. 125.74.in-addr.arpa. 61161 IN NS NS3.GOOGLE.COM. 125.74.in-addr.arpa. 61161 IN NS NS1.GOOGLE.COM. 125.74.in-addr.arpa. 61161 IN NS NS2.GOOGLE.COM. ;; ADDITIONAL SECTION: NS1.GOOGLE.COM. 71687 IN A 216.239.32.10 NS2.GOOGLE.COM. 71687 IN A 216.239.34.10 NS3.GOOGLE.COM. 83289 IN A 216.239.36.10 NS4.GOOGLE.COM. 83289 IN A 216.239.38.10 ;; Query time: 2 msec ;; SERVER: 192.168.1.3#53(192.168.1.3) ;; WHEN: Tue Oct 11 17:36:46 2011 ;; MSG SIZE rcvd: 224
Y si nos interesa obtener una salida corta, sólo con el nombre,
shell> dig -x 74.125.39.104 +short fx-in-f104.1e100.net.
Por defecto, como ya se dijo dig consulta el/los servidores configurados en nuestro sistema para realizar las peticiones, pero también permite realizar las preguntas de un servidor DNS concreto. Para ello, se usa el comodón @SERVE_NAME.
shell> dig MX @213.60.244.3 google.com ; <<>> DiG 9.7.3 <<>> MX @213.60.244.3 google.com ; (1 server found) ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode:QUERY, status:NOERROR, id:61652 ;; flags: qr rd ra; QUERY:1, ANSWER:5, AUTHORITY:4, ADDITIONAL:9 ;; QUESTION SECTION: ;google.com. IN MX ;; ANSWER SECTION: google.com. 600 IN MX 10 aspmx.l.google.com. google.com. 600 IN MX 20 alt1.aspmx.l.google.com. google.com. 600 IN MX 30 alt2.aspmx.l.google.com. google.com. 600 IN MX 40 alt3.aspmx.l.google.com. google.com. 600 IN MX 50 alt4.aspmx.l.google.com. ;; AUTHORITY SECTION: google.com. 1788 IN NS ns2.google.com. google.com. 1788 IN NS ns1.google.com. google.com. 1788 IN NS ns4.google.com. google.com. 1788 IN NS ns3.google.com. ;; ADDITIONAL SECTION: aspmx.l.google.com. 293 IN A 209.85.227.26 alt1.aspmx.l.google.com. 293 IN A 74.125.39.26 alt2.aspmx.l.google.com. 293 IN A 74.125.43.26 alt3.aspmx.l.google.com. 293 IN A 74.125.127.26 alt4.aspmx.l.google.com. 293 IN A 74.125.65.26 ns1.google.com. 16126 IN A 216.239.32.10 ns2.google.com. 16126 IN A 216.239.34.10 ns3.google.com. 13149 IN A 216.239.36.10 ns4.google.com. 13149 IN A 216.239.38.10 ;; Query time: 57 msec ;; SERVER: 213.60.244.3#53(213.60.244.3) ;; WHEN: Mon Oct 24 13:06:50 2011 ;; MSG SIZE rcvd: 352
No hay comentarios :
Publicar un comentario