Show Menu

dig (english) by


dig [@server] [-b address] [-c class] [-f filename] [-k filename] [-m] [-p port#] [-q name] [-t type] [-x addr] [-y [hmac:­]na­me:key] [-4] [-6] [name] [type] [class] [query­opt...]


Tired of always typing the same options ? Create a Run Control file for dig.
vi $HOME/.digrc
$ cat $HOME/.digrc
+noall +answer

List specific types of RRs (Resource Records)

List address records
dig -t A
List aliases
dig -t CNAME
Find who manages a domain
dig -t SOA
List mail servers
dig MX
List name servers
dig NS
List any type of Resource Record
dig ANY
There are about 40 DNS Resources Records types, but you only have to know 5 of them:

- A : Address record (IPv4); AAAA for IPv6,
- CNAME : Canonical Name. Aliases to A or AAAA records,
- SOA : Start Of Authority: primary name server, email of the domain admin, domain serial number, and timers relating to refreshing the zone,
- MX : Mail eXchange. Points to a mail server,
- NS : Name Server (a DNS).

Output sections

Displays the dig command version, the global options used, the type of operation (opcode), the status of the operation (NOERROR) and the message id (necessary to match responses to queries).
This is your input, the question that has been asked to the DNS.
The 2nd field is the time in seconds that the record may be cached (0 = don't cache), the 3rd field is the class (Internet (IN), Chaos (CH), Hesiod (HS)...), the 4th is the type (A, NS, CNAME, MX...) and the 5th, the IP.
This section contains the DNS name server that has the authority to answer your query (type: NS, Name Server).
The additional section carries Resource Records related to the RRs from the other sections.
Displays the time it took to get an answer, the IP of the DNS server used, the date and size of the message.
If you ever get confused about whether or not dig found any result for your query, check the ANSWER field from the header; if it's at 0, your query returned no proper answer.

Batch mode: multiple queries in one go

Using a list
dig -f names.list
Using several arguments
dig MX +noall +answer suckle­ ANY +short
Batch mode takes a filename as input; the file must be plain text and contain one domain per line:

$ cat names.list

Make that DNS talk !

Display only the ANSWER section
dig opensu­ +noall +answer
Activate the short output
dig +short
Reverse DNS (get name from IP)
dig -x 208.97.17­7.124
Use a specific DNS server
dig @
Display the name resolution path
dig +trace
Request a zone transfer
dig micros­ AXFR
A zone transfer is a mechanism allowing an admini­strator to replicate DNS databases across a set of DNS servers. There are two methods: full (aka AXFR) and increm­ental (aka IXFR). Zone transfers were often used by people wanting to retrieve a list of all the Resource Records of a DNS server. Nowadays, most servers will refuse your request, mostly for security reasons.


No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          More Cheat Sheets by TME520

          Chinois - Routines de conversation 1 Cheat Sheet
          Wardriving Quick Reference Cheat Sheet
          Slack messages formatting Cheat Sheet