This tutorial will show you how to query a Domain Name System (DNS) name servers for records, and how
to specify which DNS server to query, using the DIG (domain information groper) command-line tool.
Using the DIG command-line tool, you can find DNS records for different domain names, such as google.com, bing.com,
and hotmail.com, and you can query different DNS servers, such as Google's public DNS server."
From the DIG command-line tool prompt, run "dig google.com." You will see the DIG command output.
Look at the "ANSWER SECTION," which shows you the answer (it displays "A" records of google.com)
Unless otherwise specified, the DIG command-line tool displays "A" records by default.
You can also query specific records using DIG command, for example, a MX record.
From the command prompt run "dig google.com MX."
You will see that the ANSWER SECTION displays the MX records and the "ADDITIONAL SECTION" displays "A" records
of Google's MX hosts.
You can also query Name Servers or (NS) records. Simply use the NS type in your query. Run "dig google.com NS"
at the command prompt.
The output is displayed in the "ANSWER SECTION," and the "ADDITIONAL SECTION" displays "A" records of Google's
If you, for example, want to know the name of some host and all you have is its external IP address, you can do
it by performing a reverse DNS lookup, using "dig x".
In the command prompt, run "dig x 18.104.22.168" The "ANSWER SECTION" will display the host name that belongs to the
22.214.171.124 IP address, which is one of Google's public DNS servers.
If you want to use a different DNS server to perform the query, you can do it by specifying the DNS server in
the command line.
By default, DIG uses servers defined in the /etc/resolv.conf configuration file.
If you run, "dig @126.96.36.199 bing.com," the "ANSWER SECTION" displays an "A" record for bing.com domain. In the
stats section below that, "SERVER:" displays what DNS server you queried directly.
You can use this method to find answers for any type of DNS records
For example, you can query Google's public DNS server for a TXT record of hotmail.com domain.
In the command prompt, if you run firstname.lastname@example.org hotmail.com TXT, the "ANSWER SECTION" will display hotmail's
For more information about the DIG command-line tool and a list of detailed options available, at the
command prompt, run "man dig."