Dit deel is nog niet vertaald. Je ziet de Engelse tekst.
Wat het doet
dig NAME TYPE @SERVER sends a DNS query and prints the question, the answer, the authority section and statistics (server, time). Without a server it uses the servers in /etc/resolv.conf.
Options with + change the query and the output: +short gives only the answer, +trace follows the delegation from the root servers. dig asks DNS only — not /etc/hosts; use getent hosts to see what programs get.
Zo schrijf je het
dig [@SERVER] [NAME] [TYPE] [CLASS] [OPTION]... [+QUERY-OPTION]...
dig -x ADDRESSBelangrijkste delen
@SERVER- The DNS server to ask (name or IP).
NAME- The name to look up.
TYPE- Record type: A, AAAA, MX, NS, TXT, CNAME, SOA, PTR, SRV, CAA, ANY …
Opties 42
Meest gebruikt
Options
Query options (+)
Niets past bij dit filter.
Voorbeelden 12
$ als gewone gebruiker# als root (of met sudo)
1Look up an address
dig www.redhat.com +short www.redhat.com.edgekey.net. e3396.dscx.akamaiedge.net. 23.40.100.73CNAMEs first, then the IP.
2Ask a chosen server
dig @192.168.122.1 server2.example.comCompare servers when only some clients fail.
3Only the answer section
dig example.com MX +noall +answer example.com. 3600 IN MX 10 mail.example.com.Name, TTL, class, type, data.
4Reverse lookup
dig -x 192.168.122.20 +short server2.example.com.Mail servers and SSH logs use reverse DNS.
5Follow the delegation
dig +trace s0sta.comShows root → .com → your name servers; finds wrong NS records.
6Check mail security records
dig s0sta.com TXT +short; dig _dmarc.s0sta.com TXT +shortSPF and DMARC protect against spoofed mail.
7Check the name servers and SOA
dig s0sta.com NS +short; dig s0sta.com SOA +shortThe SOA serial must grow after every zone change.
8See the TTL before a migration
dig www.s0sta.com A +noall +answer +ttlunitsLower the TTL a day before you change the IP.
9Check DNSSEC
dig s0sta.com A +dnssec +multilineRRSIG records show that the zone is signed.
10Test a server's own data
dig @ns1.example.com example.com SOA +norecurseAn authoritative server must answer without recursion.
11Find open resolvers (security, own servers only)
dig @203.0.113.10 www.google.com +shortYour public DNS server should not answer for other domains.
12Many names from a file
dig -f names.txt +shortOne name per line.
Niets past bij dit filter.
Let op
- dig ignores /etc/hosts. A name can work in a browser and fail in dig (or the other way).
- The answer may come from a cache: check the TTL.
Bestanden
/etc/resolv.conf- Default DNS servers and search domains.
~/.digrc- Default dig options.
Exitcodes
0 :: An answer came (also NXDOMAIN). 1 :: Wrong syntax. 8 :: Could not open the batch file. 9 :: No reply from the server. 10 :: Internal error.