Resolving domain names with dig

Want to support HowtoForge? Become a subscriber!
 
Submitted by till (Contact Author) (Forums) on Mon, 2006-08-07 16:09. :: DNS

To resolve a domain name on the shell, you can use the command dig. Resolving the domain example.com:

dig example.com

If thedomain can be resolved, the result will be similar to this:

;  DiG 9.2.1  howtoforge.com
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 42946
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;example.com. IN A

;; ANSWER SECTION:
example.com. 84600 IN A 192.168.0.1

;; Query time: 27 msec
;; SERVER: 212.227.21.251#53(212.227.21.251)
;; WHEN: Wed Oct 26 18:53:32 2005
;; MSG SIZE rcvd: 48

To check if the local webserver is responsible for this domain use the following command:

dig @localhost example.com

If you want to know which mailserver is responsible for handling the mail for example.com, you can use the command:

dig MX example.com

The result will be similar to this:

;  DiG 9.2.1  MX howtoforge.com
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 36769
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;example.com. IN MX

;; ANSWER SECTION:
example.com. 84600 IN MX 10 mail.example.com.

;; Query time: 44 msec
;; SERVER: 212.227.21.251#53(212.227.21.251)
;; WHEN: Wed Oct 26 18:55:37 2005
;; MSG SIZE rcvd: 53

To get all available options for the dig command, you can run:

dig --help

A more detailed description you will find in the manpage of the dig command:

man dig


Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.