Skip to content
Explore the learning library ☟
SanchitGurukulTechnology · Education · Innovation Take a quiz

Advanced DNS Querying with dig Command: Complete Guide

Dig Command

Domain Information Groper (dig) command is a powerful command-line tool for querying DNS (Domain Name System) servers to retrieve DNS information. It provides various options to customize queries and obtain detailed DNS data. Here are some commonly used dig command options.

Dig Command Options

  1. @server: Specifies the DNS server to query. For example:
Command
dig @8.8.8.8 example.com

This queries the DNS server at 8.8.8.8 for the example.com domain.

  1. +type: Specifies the type of DNS record to query for. For example:
Command
dig +mx example.com

This queries for mail exchange (MX) records for the example.com domain.

  1. +short: Displays a concise output, useful for scripts or automation. For example:
Command
dig +short A example.com

This retrieves the IPv4 address associated with example.com in a compact format.

  1. +trace: Enables tracing of the DNS query, showing each step of the resolution process. For example:
Command
dig +trace example.com

This traces the DNS resolution process for the example.com domain.

  1. +recurse and +norecurse: Specifies whether to perform recursive queries. For example:
Command
dig +recurse example.com

This instructs the DNS server to perform recursive queries for the example.com domain.

  1. +timeout=X: Sets the query timeout in seconds. For example:
Command
dig +timeout=5 example.com

This sets the query timeout to 5 seconds for the example.com domain.

  1. +class: Specifies the DNS query class. The default is IN (Internet). For example:
Command
dig +class=CH example.com

This queries for Chaos class DNS records for the example.com domain.

  1. +all: Displays all information available for a query. For example:
Command
dig +all example.com

This displays all information, including header, question, answer, authority, and additional sections.

  1. +multiline: Displays output in a multi-line format for easier readability. For example:
Command
dig +multiline example.com

This provides a more detailed output with each section on a separate line.

  1. +notcp: Forces dig to use UDP instead of TCP for queries. For example:
Command
dig +notcp example.com

This performs the DNS query using UDP instead of TCP.

  1. +dnssec: Requests DNSSEC (DNS Security Extensions) records in the response. For example:
Command
dig +dnssec example.com

This queries for DNSSEC records associated with the example.com domain.

  1. +sigchase: Enables signature chasing. This option follows the chain of signatures while attempting to verify DNSSEC signatures. For example:
Command
dig +sigchase example.com

This performs signature chasing for DNSSEC validation of the example.com domain.

  1. +qr: Shows only the question section of the DNS response. For example:
Command
dig +qr example.com

This displays only the question section of the DNS response for the example.com domain.

  1. +answer: Shows only the answer section of the DNS response. For example:
Command
dig +answer example.com

This displays only the answer section of the DNS response for the example.com domain.

  1. +authority: Shows only the authority section of the DNS response. For example:
Command
dig +authority example.com

This displays only the authority section of the DNS response for the example.com domain.

  1. +additional: Shows only the additional section of the DNS response. For example:
Command
dig +additional example.com

This displays only the additional section of the DNS response for the example.com domain.

  1. +comments: Shows comments in the output, if any. For example:
Command
dig +comments example.com

This displays comments, if present, in the DNS response for the example.com domain.

  1. +noquestion: Suppresses the display of the question section in the output. For example:
Command
dig +noquestion example.com

This suppresses the display of the question section in the DNS response for the example.com domain.

  1. +retry=X: Sets the number of retries in case of a query timeout. For example:
Command
dig +retry=3 example.com

This sets the number of retries to 3 in case of a query timeout for the example.com domain.

  1. +bufsize=X: Sets the UDP message size to be used for the query. For example:
Command
dig +bufsize=1024 example.com

This sets the UDP message size to 1024 bytes for the example.com domain query.

Summary – dig command

These additional options provide more control and flexibility when querying DNS servers using the dig command. They allow you to customize the output and behavior of the dig command according to your specific requirements. You can explore additional options by referring to the dig manual (man dig).

Useful Links

Your feedback matters

Was this post helpful?

0 reactions

SanchitGurukul — Technology • Education • Innovation

Discussion

0 approved comments

No approved comments yet. You can start the discussion below.

Leave a Comment

No login is required. Name and email are used for moderation/security. Your email is never displayed publicly. All comments require administrator approval.

This field is not used to determine whether a comment is safe.

Plain text only. File uploads, scripts, executable code, abuse and spam are not accepted.


Discover more from SanchitGurukul

Subscribe to get the latest posts sent to your email.

Keep exploring

Related guides

Namaste! I’m SG Saarthi 👋Need help learning or finding something?