Comprehensive Guide to Using the “dig” Command with Examples

Comprehensive Guide to Using the "dig" Command with Examples

dig skybinary

The “dig” command is a command-line utility used to query and get information about DNS (Domain Name System) records, including IP addresses, domain name records, name servers, and more.

Here are some common “dig” commands with examples:

Basic DNS Query:

  • dig example.com

This command requests the DNS server for the IP address of “example.com”.

Query Specific Record Type

  • dig example.com MX

The command “dig MX example.com” in this context, requests the DNS server to provide the Mail Exchange (MX) records of example.com.

Query Specific DNS Server:

  • dig example.com @8.8.8.8

And it directs to the DNS server at address “8.8.8.8” to get the IP address for “example.com”.

Reverse DNS Lookup:

  • dig -x 8.8.8.8

This command makes a reverse DNS inquiry to determine the type of domain name given an IP address of “8.8.8.8”.

Query with Trace:

  • dig +trace example.com

That service directs you through the delegation path root name servers to the authority name servers of the domain “example.com”.

Query with Specific DNS Record Type:

  • dig example.com AAAA

The last command reminds the DNS server to find AAAA records (IPv6 records) of “www.example.com”

Query with Specific DNS Record Type and Display Full Information

  • dig +nocmd example.com ANY +multiline +noall +answer

By specifying the “ANY” flag this command gathers comprehensive information which is printed in a more detailed manner.

Query with Specific DNS Server and Port:

  • dig example.com @dns.example.com -p 5353

This command commands the DNS server “dns.example.com:5353” to resolve the IP address of “example.com”.

Check DNSSEC Records:

  • dig +dnssec example.com

Such a command checks if the resolver for “example.com” has the DNSSEC records or not through the DNS server.

Query Specific Name Server:

  • dig example.com NS @8.8.4.4

This smart command sends the DNS server with the IP address 8.8.4.4 a query for the hostname servers (NS records) of example.com.

Querying a Specific DNS Server for a Specific Record Type:

  • dig example.com A @ns1.exampledns.com

This command sends the query to the DNS records server “ns1.exampledns.com” to find the IPv4 address (A record) for “example.com”.

Querying a Domain and Showing the Query Time:

  • dig example.com +time=3

This directive helps to establish a communication between the DNS server and user system to get information about the “example.com”, and a limit of 3 seconds has been set for this search. Instead, it will result in a return within that time.

Querying Multiple DNS Servers Simultaneously:

  • dig example.com @8.8.8.8 +short

The lookup command “nslookup -query=example.com 8.8.8.8 1.1.1.1” checks both Google’s DNS server and Cloudflare’s DNS server for the IP address against the hostname “example.com”, just displaying their IP address without any other information.

Querying with TCP Protocol:

  • dig example.com +tcp

“Dig” uses UDP to look up DNS by default. This commend (command) states to use TCP instead of UDP. The main purpose of the UDP in DNS is to make DNS responses as quick as possible.

These additional dig commands provide further flexibility and options for querying DNS servers and obtaining DNS-related information.

 

Leave a Reply

Your email address will not be published. Required fields are marked *