Tecniche e strumenti per il troubleshooting di un sistema DNS

Dig

Dig – il cui nome deriva dal verbo inglese to dig (i.e.: scavare, scoprire o investigare) – è una utility presente in qualsiasi sistema operativo all’interno del quale è installato l’ambiente DNS BIND; pertanto essa è disponibile nativamente in ambiente Linux/Unix. Contrariamente a nslookup, dig non contempla una modalità interattiva, ma è disponibile solamente in modalità non interattiva o batch.

  attenzione

Utilizzare dig e host in ambito Windows

Per disporre in ambito Windows delle utility dig e host è necessario scaricare dal sito http://www.isc.org il package BIND (e.g.: http://ftp.isc.org/isc/bind/contrib/ntbind-9.3.2/BIND9.3.2.zip), e procedere con la estrazione dei file in una directory (e.g.: c:\bind9.3.2).

Alcuni esempi di utilizzo dell’utility dig sono mostrati di seguito.

Alcuni esempi di utilizzo dell’utility dig
  • Help (sintassi del comando dig):

    dig –h

Esempio:

c:\etc\dig -h

Usage: dig [@global-server] [domain] [q-type] [q-class] {q-opt}

{global-d-opt} host [@local-server] {local-d-opt}

[ host [@local-server] {local-d-opt} [...]]

Where: domain is in the Domain Name System

q-class is one of (in,hs,ch,...) [default: in]

q-type is one of (a,any,mx,ns,soa,hinfo,axfr,txt,...) [default:a]

(Use ixfr=version for type ixfr)

q-opt is one of:

-x dot-notation (shortcut for in-addr lookups)

-i (IP6.INT reverse IPv6 lookups)

-f filename (batch mode)

-b address[#port] (bind to source address/port)

-p port (specify port number)

-t type (specify query type)

-c class (specify query class)

-k keyfile (specify tsig key file)

-y name:key (specify named base64 tsig key)

-4 (use IPv4 query transport only)

-6 (use IPv6 query transport only)

d-opt is of the form +keyword[=value], where keyword is:

+[no]vc (TCP mode)

+[no]tcp (TCP mode, alternate syntax)

+time=### (Set query timeout) [5]

+tries=### (Set number of UDP attempts) [3]

+retry=### (Set number of UDP retries) [2]

+domain=### (Set default domainname)

+bufsize=### (Set EDNS0 Max UDP packet size)

+ndots=### (Set NDOTS value)

+[no]search (Set whether to use searchlist)

+[no]defname (Ditto)

+[no]recurse (Recursive mode)

+[no]ignore (Don't revert to TCP for TC responses.)

+[no]fail (Don't try next server on SERVFAIL)

+[no]besteffort (Try to parse even illegal messages)

+[no]aaonly (Set AA flag in query (+[no]aaflag))

+[no]adflag (Set AD flag in query)

+[no]cdflag (Set CD flag in query)

+[no]cl (Control display of class in records)

+[no]cmd (Control display of command line)

+[no]comments (Control display of comment lines)

+[no]question (Control display of question)

+[no]answer (Control display of answer)

+[no]authority (Control display of authority)

+[no]additional (Control display of additional)

+[no]stats (Control display of statistics)

+[no]short (Disable everything except short

form of answer)

+[no]ttlid (Control display of ttls in records)

+[no]all (Set or clear all display flags)

+[no]qr (Print question before sending)

+[no]nssearch (Search all authoritative nameservers)

+[no]identify (ID responders in short answers)

+[no]trace (Trace delegation down from root)

+[no]dnssec (Request DNSSEC records)

+[no]multiline (Print records in an expanded format)

global d-opts and servers (before host name) affect all queries.

local d-opts and servers (after host name) affect only that lookup.

-h (print help and exit)

-v (print version and exit)

  • Numero di versione della utility dig:

dig –v

Esempio:

c:\etc\dig -v

DiG 9.3.2

  • Come determinare la versione di un server DNS BIND (naturalmente, come già detto a proposito del comando nslookup, l’esito di questo comando dipende dalla configurazione del server BIND e dalla possibilità che l’amministratore abbia o meno filtrato tale risposta):

dig @<indirizzo-IP-server-DNS> txt chaos version.bind

Esempio:

- c:\etc\dig @193.205.245.5 chaos txt version.bind

Oppure:

- c:\etc\dig @193.205.245.5 txt chaos version.bind

; <<>> DiG 9.3.2 <<>> @193.205.245.5 txt chaos version.bind

; (1 server found)

;; global options: printcmd

;; Got answer:

;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 1003

;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 0

;; QUESTION SECTION:

;version.bind.CHTXT

;; ANSWER SECTION:

version.bind.0CHTXT"9.3.1"

;; AUTHORITY SECTION:

version.bind.0CHNSversion.bind.

;; Query time: 15 msec

;; SERVER: 193.205.245.5#53(193.205.245.5)

;; WHEN: Sun Feb 05 15:03:51 2006

;; MSG SIZE rcvd: 62

  • Query di reverse (i.e.: a partire da un indirizzo IP risalire al nome di un host):

dig @<indirizzo-IP-server-DNS> -x <indirizzo-IP-oggetto-della-query>

Esempio:

c:\etc\dig @dns.nic.it -x 193.205.245.15

; <<>> DiG 9.3.2 <<>> @dns.nic.it -x 193.205.245.15

; (1 server found)

;; global options: printcmd

;; Got answer:

;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 1537

;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 3

;; QUESTION SECTION:

;15.245.205.193.in-addr.arpa. IN PTR

;; ANSWER SECTION:

15.245.205.193.in-addr.arpa. 3600 IN PTR hp4550.nic.it.

;; AUTHORITY SECTION:

245.205.193.in-addr.arpa. 432000 IN NS dns.nic.it.

245.205.193.in-addr.arpa. 432000 IN NS nameserver.cnr.it.

;; ADDITIONAL SECTION:

dns.nic.it. 86400 IN A 193.205.245.5

dns.nic.it. 86400 IN AAAA 2001:760:4000:1f5::5

nameserver.cnr.it. 72368 IN A 194.119.192.34

;; Query time: 187 msec

;; SERVER: 193.205.245.5#53(193.205.245.5)

;; WHEN: Sun Feb 05 19:11:33 2006

;; MSG SIZE rcvd: 179

  • Query multiple: elencare tutti i RR contenuti in due zone/domini gestite da uno server DNS/BIND:

dig @<indirizzo-IP-server-DNS> <FQDN-dominio> -t <any> <FQDN-dominio> -t <any>

Esempio:

C:\dig>dig @212.25.160.10 learning-solutions.it -t any silmarconsulting.it -t any

;; Got answer:

;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 1776

;; flags: qr aa rd; QUERY: 1, ANSWER: 8, AUTHORITY: 0, ADDITIONAL: 15

;; QUESTION SECTION:

;learning-solutions.it. IN ANY

;; ANSWER SECTION:

learning-solutions.it. 172800 IN SOA dns.seeweb.it. hostmaster.seeweb.it. 2005030300 86400 7200 2592000 86400

learning-solutions.it. 172800 IN NS dns2.seeweb.it.

learning-solutions.it. 172800 IN NS dns.seeweb.it.

learning-solutions.it. 172800 IN MX 10 wnx-5b.seeweb.it.

learning-solutions.it. 172800 IN MX 20 smtp-f1.seeweb.it.

learning-solutions.it. 172800 IN MX 20 smtp-f2.seeweb.it.

learning-solutions.it. 172800 IN MX 20 smtp-f3.seeweb.it.

learning-solutions.it. 172800 IN MX 20 smtp-f4.seeweb.it.

;; ADDITIONAL SECTION:

dns.seeweb.it. 172800 IN A 212.25.160.10

dns2.seeweb.it. 172800 IN A 217.64.196.10

wnx-5b.seeweb.it. 172800 IN A 212.25.179.6

smtp-f1.seeweb.it. 172800 IN A 212.25.179.65

smtp-f1.seeweb.it. 172800 IN A 212.25.179.69

smtp-f1.seeweb.it. 172800 IN A 212.25.179.73

smtp-f2.seeweb.it. 172800 IN A 212.25.179.74

smtp-f2.seeweb.it. 172800 IN A 212.25.179.66

smtp-f2.seeweb.it. 172800 IN A 212.25.179.70

smtp-f3.seeweb.it. 172800 IN A 212.25.179.71

smtp-f3.seeweb.it. 172800 IN A 212.25.179.75

smtp-f3.seeweb.it. 172800 IN A 212.25.179.67

smtp-f4.seeweb.it. 172800 IN A 212.25.179.76

smtp-f4.seeweb.it. 172800 IN A 212.25.179.68

smtp-f4.seeweb.it. 172800 IN A 212.25.179.72

;; Query time: 406 msec

;; SERVER: 212.25.160.10#53(212.25.160.10)

;; WHEN: Sun Feb 05 15:49:41 2006

;; MSG SIZE rcvd: 489

; <<>> DiG 9.3.2 <<>> @212.25.160.10 learning-solutions.it -t any silmarconsulting.it -t any

; (1 server found)

;; global options: printcmd

;; Got answer:

;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 1563

;; flags: qr aa rd; QUERY: 1, ANSWER: 4, AUTHORITY: 0, ADDITIONAL: 2

;; QUESTION SECTION:

;silmarconsulting.it. IN ANY

;; ANSWER SECTION:

silmarconsulting.it. 172800 IN SOA dns.seeweb.it. hostmaster.seeweb.it. 2002112100 86400 7200 2592000 86400

silmarconsulting.it. 172800 IN NS dns.seeweb.it.

silmarconsulting.it. 172800 IN NS dns2.nic.it.

silmarconsulting.it. 172800 IN MX 10 mail.silmarconsulting.it.

;; ADDITIONAL SECTION:

dns.seeweb.it. 172800 IN A 212.25.160.10

mail.silmarconsulting.it. 172800 IN A 212.25.170.113

;; Query time: 250 msec

;; SERVER: 212.25.160.10#53(212.25.160.10)

;; WHEN: Sun Feb 05 15:49:41 2006

;; MSG SIZE rcvd: 185

  • Interpretazione dell’output del comando dig:

Il formato dell’output del comando dig prevede cinque parti o sezioni:

  • Sezione Flags e Status:

    In questa prima parte dell’output, sono visualizzate alcune informazioni riguardanti i Flag e lo Status relativo al tipo di risposta ottenuta.

    Alcuni parametri utilizzati dal comando dig sono i seguenti:

    • Flags: qr (Query/Response); aa (Authoritative Answer); rd (Recursion Desidered); ra (Recursion Available); ad (Authenticated Data); cd (Checking Disabled); ds (DNSSEC OK).

    • Status: NOERR (No Error Condition); FORMERR (Format Error: il server DNS non è stato in grado di interpretare la query a causa di un errore nel suo formato); SERVFAIL (Server Failure: il server DNS non è stato in grado di interpretare la query; ciò può accadere o per problemi con il server o perchè il nome richiesto non è un FQDN “ben-formato” (e.g.: è stato inviato solamente il nome host senza nessun suffisso DNS) oppure a causa di funzionalità non disponibili (e.g.: una query ricorsiva rivolta ad un server sul quale questo tipo di query sono state disabilitate); NXDOMAIN (Non eXistent Domain: segnala che il nome DNS o il suffisso specificato nella query è ineesistente); NOTIMP (Not Implemented (per le versioni BIND precedenti alla 9.3 il codice di errore potrebbe essere NOTIMPL): il server DNS non supporta l’operazione richiesta); REFUSED (il server DNS rifiuta le operazioni richieste (e.g.: una richiesta di Full Zone Transfer (AXFR))); YXDOMAIN (Il server DNS segnala che il nome di dominio esiste quando invece non dovrebbe (cf. RFC 2136)); YXRRSet (Il server DNS segnala che il RR esiste quando invece non dovrebbe (cf. RFC 2136)); NXRRSet (Il server DNS segnala che il RR che dovrebbe esistere invece non è stato trovato (cf. RFC 2136)); NotAuth (Il server DNS non è autoritativo per la zona in questione (cf. RFC 2136)); NotZone (Il server DNS segnala che il nome cercato non appartiene alla zona in questione (cf. RFC 2136)).

Per ulteriori informazioni sui suddetti codici di errore si rimanda il lettore al Cap. 5, sezione “Struttura della sezione Header” di una PDU DNS (cf. anche la tabella 14, sempre nel Cap. 5).

  • Sezione Question (query o interrogazione): contiene la richiesta inoltrata al server DNS.
  • Sezione Answer (risposta): contiene le risposte alla query.
  • Sezione Authority (risposta): contiene la lista dei server DNS autoritativi per la zona/dominio considerato.
  • Sezione Additional (risposta): contiene eventuali informazioni addizionali importanti per completare la risoluzione desiderata (e.g.: i RR A relativi ad altri server DNS autoritativi per i RR richiesti). Ciò accade, ad esempio, nel caso di sottomissione della query dig @193.205.245.5 learning-solutions.it any. Infatti, non essendo il server DNS 193.205.245.5 autoritativo per la zona learning-solutions.it, il comando dig fornisce i FQDN ed i relativi RR A per identificare univocamente i server DNS autoritativi per il dominio learning-solutions.it.
  • Sezione Question (query o interrogazione): contiene la richiesta inoltrata al server DNS.
  • Forzare una operazione di Full Zone Transfer:

dig @<indirizzo-IP-server-DNS> <FQDN-dominio> axfr

Esempio:

C:\dig>dig @192.168.0.201 isoleeolie2003.org. axfr

; <<>> DiG 9.3.2 <<>> @192.168.0.201 isoleeolie2003.org. axfr

; (1 server found)

;; global options: printcmd

isoleeolie2003.org. 3600 IN SOA calajunco-2k3.isoleeolie2003.org. leoner.isoleeolie2003.org. 47 900 600 86400 3600

isoleeolie2003.org. 600 IN A 192.168.0.230

isoleeolie2003.org. 3600 IN NS calajunco-2k3.isoleeolie2003.org.

_kerberos._tcp.default-first-site-name._sites.dc._msdcs.isoleeolie2003.org. 600 IN SRV 0 100 88 ie-mi-dc-01.isoleeolie2003.org.

_ldap._tcp.default-first-site-name._sites.dc._msdcs.isoleeolie2003.org. 600 IN SRV 0 100 389 ie-mi-dc-01.isoleeolie2003.org.

_kerberos._tcp.dc._msdcs.isoleeolie2003.org. 600 IN SRV 0 100 88 ie-mi-dc-01.isoleeolie2003.org.

_ldap._tcp.dc._msdcs.isoleeolie2003.org. 600 IN SRV 0 100 389 ie-mi-dc-01.isoleeolie2003.org.

_ldap._tcp.56a8a918-d321-46bc-881d-cc58bf0e6f9b.domains._msdcs.isoleeolie2003.org. 600 IN SRV 0 100 389 ie-mi-dc-01.isoleeolie2003.org.

e886b836-966c-4e26-8eb6-bdec708da42b._msdcs.isoleeolie2003.org. 600 IN CNAME ie-mi-dc-01.isoleeolie2003.org.

gc._msdcs.isoleeolie2003.org. 600 IN A 192.168.0.230

_ldap._tcp.default-first-site-name._sites.gc._msdcs.isoleeolie2003.org. 600 IN SRV 0 100 3268 ie-mi-dc-01.isoleeolie2003.org.

_ldap._tcp.gc._msdcs.isoleeolie2003.org. 600 IN SRV 0 100 3268 ie-mi-dc-01.isoleeolie2003.org.

_ldap._tcp.pdc._msdcs.isoleeolie2003.org. 600 IN SRV 0 100 389 ie-mi-dc-01.isoleeolie2003.org.

_gc._tcp.default-first-site-name._sites.isoleeolie2003.org. 600 IN SRV 0 100 3268 ie-mi-dc-01.isoleeolie2003.org.

_kerberos._tcp.default-first-site-name._sites.isoleeolie2003.org. 600 IN SRV 0 100 88 ie-mi-dc-01.isoleeolie2003.org.

_ldap._tcp.default-first-site-name._sites.isoleeolie2003.org. 600 IN SRV 0 100 389 ie-mi-dc-01.isoleeolie2003.org.

_gc._tcp.isoleeolie2003.org. 600 IN SRV 0 100 3268 ie-mi-dc-01.isoleeolie2003.org.

_kerberos._tcp.isoleeolie2003.org. 600 IN SRV 0 100 88 ie-mi-dc-01.isoleeolie2003.org.

_kpasswd._tcp.isoleeolie2003.org. 600 IN SRV 0 100 464 ie-mi-dc-01.isoleeolie2003.org.

_ldap._tcp.isoleeolie2003.org. 600 IN SRV 0 100 389 ie-mi-dc-01.isoleeolie2003.org.

_kerberos._udp.isoleeolie2003.org. 600 IN SRV 0 100 88 ie-mi-dc-01.isoleeolie2003.org.

_kpasswd._udp.isoleeolie2003.org. 600 IN SRV 0 100 464 ie-mi-dc-01.isoleeolie2003.org.

calajunco-2k3.isoleeolie2003.org. 3600 IN A 192.168.193.1

calajunco-2k3.isoleeolie2003.org. 3600 IN A 192.168.93.1

calajunco-2k3.isoleeolie2003.org. 3600 IN A 192.168.0.201

domaindnszones.isoleeolie2003.org. 600 IN A 192.168.0.230

_ldap._tcp.default-first-site-name._sites.domaindnszones.isoleeolie2003.org. 600 IN SRV 0 100 389 ie-mi-dc-01.isoleeolie2003.org.

_ldap._tcp.domaindnszones.isoleeolie2003.org. 600 IN SRV 0 100 389 ie-mi-dc-01.isoleeolie2003.org.

forestdnszones.isoleeolie2003.org. 600 IN A 192.168.0.230

_ldap._tcp.default-first-site-name._sites.forestdnszones.isoleeolie2003.org. 600 IN SRV 0 100 389 ie-mi-dc-01.isoleeolie2003.org.

_ldap._tcp.forestdnszones.isoleeolie2003.org. 600 IN SRV 0 100 389 ie-mi-dc-01.isoleeolie2003.org.

ftp.isoleeolie2003.org. 3600 IN CNAME www.isoleeolie2003.org.

www.isoleeolie2003.org. 3600 IN A 192.168.0.200

isoleeolie2003.org. 3600 IN SOA calajunco-2k3.isoleeolie2003.org. leoner.isoleeolie2003.org. 47 900 600 86400 3600

;; Query time: 515 msec

;; SERVER: 192.168.0.201#53(192.168.0.201)

;; WHEN: Sun Feb 05 19:23:24 2006

;; XFR size: 34 records (messages 34)

E’ da notare che l’esito del suddetto comando dipende dalla configurazione della zona DNS. Infatti, esso richiede l’autorizzazione allo Zone Transfer verso un prefissato insieme di indirizzi IP oppure verso tutti gli host (deprecabile a livello di sicurezza).

  • Forzare una operazione di Full Zone Transfer in presenza di una implementazione TSIG per la crittografia delle operazioni di Zone Transfer:

dig @192.168.0.201 guidadns.it AXFR –k Kdns1-dns2.+157+19475.private

dove Kdns1-dns2.+157+19475.private rappresenta il file che contiene la chiave condivisa utilizzata per la crittografia.

  • Rilevare i RR MX (i.e.: i server SMTP) per un determinato dominio:

dig @<indirizzo-IP-server-DNS> <FQDN-dominio> -t mx

Esempio:

C:\dig>dig @212.25.160.10 silmarconsulting.it -t mx

; <<>> DiG 9.3.2 <<>> @212.25.160.10 silmarconsulting.it -t mx

; (1 server found)

;; global options: printcmd

;; Got answer:

;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 1369

;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 2

;; QUESTION SECTION:

;silmarconsulting.it. IN MX

;; ANSWER SECTION:

silmarconsulting.it. 172800 IN MX 10 mail.silmarconsulting.it.

;; AUTHORITY SECTION:

silmarconsulting.it. 172800 IN NS dns.seeweb.it.

silmarconsulting.it. 172800 IN NS dns2.nic.it.

;; ADDITIONAL SECTION:

mail.silmarconsulting.it. 172800 IN A 212.25.170.113

dns.seeweb.it. 172800 IN A 212.25.160.10

;; Query time: 281 msec

;; SERVER: 212.25.160.10#53(212.25.160.10)

;; WHEN: Sun Feb 05 15:55:53 2006

;; MSG SIZE rcvd: 138

  • Identificare il server DNS primario per una data zona/dominio, tramite rilevazione del RR SOA:

dig @<indirizzo-IP-server-DNS> <FQDN-dominio> -t soa

Esempio:

C:\dig>dig @193.205.245.66 nic.it soa

; <<>> DiG 9.3.2 <<>> @193.205.245.66 nic.it soa

; (1 server found)

;; global options: printcmd

;; Got answer:

;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 148

;; flags: qr rd; QUERY: 1, ANSWER: 1, AUTHORITY: 4, ADDITIONAL: 2

;; QUESTION SECTION:

;nic.it. IN SOA

;; ANSWER SECTION:

nic.it. 84078 IN SOA dns.nic.it. hostmaster.nic.it. 2006011900 86400 1800 604800 86400

;; AUTHORITY SECTION:

nic.it. 84298 IN NS dns2.nic.it.

nic.it. 84298 IN NS itgeo.mix-it.net.

nic.it. 84298 IN NS nameserver.cnr.it.

nic.it. 84298 IN NS dns.nic.it.

;; ADDITIONAL SECTION:

itgeo.mix-it.net. 521 IN A 217.29.76.5

nameserver.cnr.it. 86400 IN A 194.119.192.34

;; Query time: 265 msec

;; SERVER: 193.205.245.66#53(193.205.245.66)

;; WHEN: Tue Feb 07 11:16:33 2006

;; MSG SIZE rcvd: 199

  attenzione

http://www.DNSstuff.com: un concentrato di strumenti diagnostici

DNSstuff è un sito contenente una grande varietà di strumenti utili per scopi diagnostici, analisi e test.

Essi sono organizzati in quattro categorie:

  • Domain Name Test: DNS Report, DNS Timing, WHOIS Lookup, Abuse Lookup, Domain Info.

  • IP Test: Spam database lookup, Reverse DNS lookup, IPWHOIS Lookup, City From IP.

  • Hostname Test: DNS lookup, Traceroute, Ping, ISP cached DNS lookup.

  • Other Tests: URL deobfuscator, Free E-mail Lookup, CIDR/Netmask, E-mail Test, CSE HTML Validator, Decimal IPs.

Alla URL seguente:

https://addons.mozilla.org/extensions/moreinfo.php?application=firefox&id=827

è disponibile anche l’add-on per Firefox (DNSStuff Toolbar – Firefox Extension).