Icon Celebrity Journal
general /

How to use the dig command on linux

Browse by products and services

DV and VPS Hosting

Grid Hosting

DV Developer Hosting

Legacy Managed WordPress

Legacy DV Hosting

  • Applies to: All Service Types
    • Difficulty: Medium
    • Time Needed: 10
    • Tools Required: None

Overview

The command dig is a tool for querying DNS nameservers for information about host addresses, mail exchanges, nameservers, and related information. This tool can be used from any Linux (Unix) or Macintosh OS X operating system. The most typical use of dig is to simply query a single host.

Instructions

Run the command:

View the Output:

Understanding the Results

The opening section of dig’s output tells us a little about itself (version 9.4.1) and the global options that are set (in this case, printcmd ):

Here, dig tells us some technical details about the answer received from the DNS server. This section of the output can be toggled using the +[no]comments option—but beware that disabling the comments also turns off many section headers:

In the question section, dig reminds us of our query. The default query is for an Internet address ( A ).

Now we have our anwser, the address of mt-example.com is 205.186.150.66.

The final section of the default output contains statistics about the query; it can be toggled with the +[no]stats option.

A quick way to just get the answer only is to run the following command:

What can I find using the dig command?

dig will let you perform any valid DNS query, the most common of which are:

  • A (the IP address),
  • TXT (text annotations),
  • MX (mail exchanges), and
  • NS nameservers.

Use the following command to get the addresses for mt-example.com.

Use the following command to get a list of all the mailservers for mt-example.com.

Use the following command to get a list of authoritative DNS servers for mt-example.com.

Use the following command to get a list of all the above in one set of results.

Use the following command to query using a specific nameserver.