Query the DNS server
$ dig [domain]
- query dns server for name
$ dig +nocmd [domain]
- drops dig version from query output
$ dig +nocomments [domain]
- drops the question and answer section from query output
$ dig +noquestion [domain]
- drops the question from the query output
$ dig +noanswer [domain]
- drops the answer from the query output
$ dig +noauthority [domain]
- drops the information of authoritative dns from the query output
$ dig +noadditional [domain]
- drops additional information from query output
$ dig +nostat [domain]
- drops statistics from query output
$ dig +short [domain]
- short form of query output
$ dig [DNS_record] [domain]
- query dns for given DNS record
$ dig [domain] AXFR
- zone transfer
$ dig -x [ip_addres]
- reverse dns lookup
$ dig @nameserver [domain]
- query different name server
$ dig +search [domain]
- uses dns servers from /etc/resolv.conf
$ dig -f /path/to/file
- query for hosts specified in the file
$ dig +noall
- set or clear all display flags
Example
$ dig @8.8.8.8 hack.com
; <<>> DiG 9.8.3-P1 <<>> @8.8.8.8 hackme.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 39044
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;hackme.com. IN A
;; ANSWER SECTION:
hackme.com. 299 IN A 69.172.201.208
;; Query time: 91 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Thu Mar 12 21:50:25 2015
;; MSG SIZE rcvd: 44
===========================
$ dig @8.8.8.8 +short hack.com
69.172.201.208