# Troubleshooting DNS with dig and nslookup

> Query DNS servers with dig and nslookup to check records, propagation and where your domain points.

Source: https://helpcenter.ruachost.com/developers/networking/troubleshooting-dns-with-dig-and-nslookup/

When your domain is not resolving correctly, two of the most useful tools for diagnosing DNS issues are `dig` (on Linux/macOS) and `nslookup` (on Windows). These tools let you query DNS servers directly to see how your domain is configured.

## Why Use These Tools?

- Verify if your domain points to the correct IP address.
- Check if DNS propagation is complete.
- Inspect specific DNS records (A, MX, CNAME, TXT, etc.).
- Identify misconfigurations between your registrar and hosting provider.

## Using Web-Based DNS Tools

If you’re not comfortable with the command line, you can use free online tools:

- [whatsmydns.net](http://www.whatsmydns.net/) → Check global DNS propagation.
- [digwebinterface.com](http://www.digwebinterface.com/) → Run `dig` queries online.

## Using `nslookup` on Windows

1. Open **Command Prompt**.
2. Run a basic query:

   ```bash
   nslookup example.com
   ```

   → Shows the IP address (A record) for the domain.
3. Query a specific DNS server→

   ```bash
   nslookup example.com 8.8.8.8
   ```

   Uses Google DNS (8.8.8.8) instead of your default resolver.
4. Look up MX (mail) records:

   ```bash
   nslookup
   set type=MX
   example.com
   ```

## Using dig on Linux/macOS

1. Open **Terminal**.
2. Run a basic query:

   ```bash
   dig example.com
   ```

   → Displays the A record for the domain.
3. Query a specific DNS server:

   ```bash
   dig @8.8.8.8 example.com
   ```
4. Look up MX records:

   ```bash
   dig example.com MX
   ```
5. Look up TXT records (useful for SPF/DKIM):

   ```bash
   dig example.com TXT
   ```

## Interpreting Results

- **ANSWER SECTION** → Shows the record returned (e.g., IP address for A record).
- **AUTHORITY SECTION** → Shows which nameservers are authoritative for the domain.
- **ADDITIONAL SECTION** → May include related records (like IPs of nameservers).
