Using dig & nslookup for DNS Debugging

dig and nslookup are powerful command-line tools for querying DNS records and troubleshooting network issues. This guide explains how to use both tools for DNS debugging effectively.

1. Using dig for DNS Queries

dig (Domain Information Groper) is a widely used tool for querying DNS records.

Basic Usage

To query an A record for a domain:

dig example.com

Output will show the queried domain, response time, and IP address.

Querying Specific Record Types

Performing Reverse DNS Lookups

To find the domain associated with an IP address:

dig -x 192.0.2.1

Querying Specific Name Servers

To query a particular DNS server, use @:

dig @8.8.8.8 example.com

2. Using nslookup for DNS Queries

nslookup is another commonly used tool for DNS debugging.

Basic Usage

To find an IP address for a domain:

nslookup example.com

Querying Specific Record Types

Using a Custom DNS Server

To specify a different DNS server:

nslookup example.com 8.8.8.8

3. Comparing dig and nslookup

Feature

dig

nslookup

Output Readability

Detailed

Simple

Supports Batch Queries

Yes

No

Reverse DNS Lookup

Yes

Yes

Custom DNS Server

Yes

Yes

4. Troubleshooting DNS Issues with dig & nslookup

Checking Domain Resolution

If a domain is not resolving:

dig example.com
nslookup example.com

Verify the DNS records are correctly configured.

Identifying Propagation Delays

Check multiple name servers:

dig @8.8.8.8 example.com

Compare results across different servers.

Conclusion

dig and nslookup are essential tools for diagnosing DNS issues, validating configurations, and ensuring network stability. Understanding their features and how to use them effectively can streamline troubleshooting processes.