Programster's Blog

Tutorials focusing on Linux, programming, and open source

Dig - DNS Querying

Dig is a DNS lookup utility that can be useful for checking your DNS is answering queries correctly.

Install Dig

One can install the dig tool with the following command

sudo apt-get install dnsutils

Query DNS

If you want to query your current default DNS for a hostname, then simply enter the command below:

dig my.domain.com

If you want to query a specific DNS, such as one you just set up, then one needs to specify it like below (substituting the IP):

dig my.domain.com @192.168.1.1

Alternatively, you can use a hostname for the nameserver, rather than the IP address, like below:

dig my.domain.com @ns1.mydomain.com

Example Output

Below is an example of the ouput from such a query.

It may be important to know that the part with ;; Server: xxx.xxx.xxx.xxx is the IP address of the DNS server that responded. This is an easy way to figure out which DNS server you are using if you do not know.