January 10, 2020 · linux Don't Forget

Dig(ging) DNS

Dig (Domain Information Groper) is a command line utility that performs DNS lookup by querying name servers and displaying the result to you.

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.

By default, the dig command will display the A record when no other options are specified. The output will also contain other information like the installed dig version, technical details about the answers, statistics about the query, a question section along with few other ones.

dig talm.ai +noall +answer

This queries the answers section only, and stops displaying all the section using +noall option.

dig @ns.talm.ai +nocmd talm.ai ANY +multiline +answer

This queries all the available DNS record types associated with a domain (ANY), disabled the initial comment of the version of dig (+nocmd), show records in a verbose multi-line format with human-readable comments (+multiline), using the specified dns server.

dig talm.ai +trace

Dig allows tracing the DNS lookup path. The option makes iterative queries to resolve the name lookup. It will query the name servers starting from the root and subsequently traverses down the namespace tree using iterative queries following referrals along the way.

dig -x 34.214.202.205

To perform a reverse DNS lookup using the dig command use the –x option followed by your chosen IP address.