Back to the command reference

dig

NetworkFundamentals In real Linux

Query DNS records

Name: dig = domain information groper

This command needs a real Linux system; you can practise it in real Linux mode.

Description

dig queries DNS servers and shows the answers in detail. It handles A, AAAA, MX, TXT, NS, CNAME and other records and can ask a specific server; the first choice for DNS troubleshooting.

Syntax

dig [@SERVER] NAME [TYPE]

Common options

TYPERecord type: A, AAAA, MX, TXT, NS …
+shortShort answer only
+noall +answerOnly the answer section (tidier than the default, fuller than +short)
+traceFollow the lookup step by step from the root servers
@8.8.8.8Ask a specific server
-x ADDRESSReverse lookup: the name of an address
-t TYPEThe record type (same as TYPE), e.g. -t MX
-p PORTThe DNS server’s port (53 by default)

Examples

  • $ dig web01.example.lan

    Look up a name’s address (full output)

    Explain
  • $ dig +short example.lan MX

    Only the mail (MX) records, briefly

    Explain
  • $ dig @127.0.0.1 db01.example.lan

    Ask a particular DNS server

    Explain

Related