Linux Terminal Command: dig

The dig command is an essential tool in Network Utilities. In this tutorial, we will explore what dig does, look at everyday examples, and cover advanced options to supercharge your command-line workflow.


Concept & Explanation

The dig (domain information groper) command is a flexible tool for querying DNS name servers, yielding detailed answer records.


Common Options & Syntax

dig [options] [arguments]

Here are the most common flags used with dig:


1. Interactive Example (Simple)

Here is how most people run the command:

# Example
dig google.com

What it does: Queries the DNS record for ‘google.com’.


2. Power-User Example (Advanced)

For scripting and advanced diagnostics, use this configuration:

# Advanced
dig @1.1.1.1 google.com MX +noall +answer

What it does: Queries Cloudflare DNS (@1.1.1.1) for ‘google.com’ mail servers, returning only the answers section.


⚙️ Warning & Common Pitfalls

[!WARNING] By default, dig prints out detailed comments, query times, and headers. Use the +short flag to return only the IP addresses.


Here are some related posts on cli_tty1 you might want to check out: