The dig (Domain Information Groper) command helps developers check DNS records and troubleshoot domain resolution on Linux. It is one of the first tools to reach for when a domain isn't behaving the way you expect.

1. Install dig

On Debian/Ubuntu-based systems, dig ships in the dnsutils package:

sudo apt update sudo apt install dnsutils 

2. Find a Domain's IP Address

dig safal.me +short 

The +short flag trims the output down to just the IP addresses found in the DNS response.

3. Check DNS Records

Pass a record type after the domain name:

dig safal.me A dig safal.me AAAA dig safal.me MX dig safal.me NS dig safal.me TXT 
Record Purpose
A IPv4 address
AAAA IPv6 address
MX Mail servers
NS Name servers
TXT Text records (SPF, domain verification, etc.)

4. Query a Specific DNS Server

dig @8.8.8.8 safal.me 

This sends the query to Google's public DNS resolver instead of your system default, which is handy for checking whether a problem is local to your resolver.

5. Trace DNS Resolution

dig safal.me +trace 

This shows the delegation process step by step, from the root servers down to the domain's authoritative name servers.

Conclusion

The dig command is a useful tool for developers and DevOps engineers troubleshooting DNS issues. Once you know these few flags, most DNS debugging becomes quick and predictable.

Next: Linux nslookup Command: Simple Examples.

About Me

I'm Safal Bhattarai, a Tech Lead, Full Stack Developer, and DevOps Engineer.

🌐 Website GitHub