Dig stands for (Domain Information Groper). Dig is a network administration command-line tool for querying Domain Name System (DNS) name servers. It is useful for verifying and troubleshooting DNS problems and also to perform DNS lookups and displays the answers that are returned from the name server that were queried. dig is part of the BIND domain name server software suite. dig command replaces older tool such as nslookup and the host. dig tool is available in major Linux distributions.
Install Dig on Linux
- apt-get install dnsutils
- yum install bind-utils
In its simplest form, the syntax of the dig utility will look like this:
- dig [server] [name] [type]
[server] – the IP address or hostname of the name server to query
If the server argument is the hostname then dig will resolve the hostname before proceeding with querying the name server.
It is optional and if you don’t provide a server argument then dig uses the name server listed in /etc/resolv.conf
[name] – the name of the resource record that is to be looked up
[type] – the type of query requested by dig. For example, it can be an A record, MX record, SOA record or any other types. By default dig performs a lookup for an A record if no type argument is specified.
Dig a Domain Name
- dig yahoo.com
UNDERSTAND THE OUTPUT:
- Lines beginning with ; are comments not part of the information.
- The first line tell us the version of dig (9.11.5) command.
- Next, dig shows the header of the response it received from the DNS server
- Next comes the question section, which simply tells us the query, which in this case is a query for the “A” record of yahoo.com. The IN means this is an Internet lookup (in the Internet class).
- The answer section tells us that yahoo.com has the IP address 220.127.116.11
- Lastly there are some stats about the query. You can turn off these stats using the +nostats option.
- dig yahoo.com +short
- dig yahoo.com +noall +answer
- dig @18.104.22.168 yahoo.com
The following dig command sends the DNS query to Google’s name server(22.214.171.124) by using the @126.96.36.199 option
Query All DNS Record Types
- dig yahoo.com ANY
Search For Record Type
- dig yahoo.com MX
- dig yahoo.com NS
- dig yahoo.com A
- dig yahoo.com SOA
Trace DNS Path
- dig yahoo.com +trace
Reverse DNS Lookup
- dig +answer -x 188.8.131.52
Reverse DNS lookup lets you look up the domain and hostname associated with an IP address.
- dig -f domain_name.txt +short
provide dig with a list of domain names – one per line in a file
- dig axfr @10.10.10.13 cronos.htb
Those different domains in the output point to the same IP.