0Pricing
Linux Networking & TCP/IP for Developers · Lesson

DNS Diagnostics with dig and nslookup

Diagnose name-resolution problems on Linux using dig, nslookup, and host to inspect DNS records, trace resolution paths, and spot misconfigurations.

DNS Diagnostics with dig and nslookup is a free Linux Networking & TCP/IP for Developers lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Linux Networking & TCP/IP for Developers learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Why DNS Diagnostics Matter

Many 'network is down' reports are really DNS failures. The host is reachable by IP, but the name will not resolve.

Linux ships tools to inspect resolution directly:

  • dig — flexible, scriptable lookups
  • nslookup — classic interactive tool
  • host — quick one-line answers

This lesson focuses on reading their output to find the real problem.

A Basic dig Query

Run dig followed by a hostname to fetch its A record.

The key part of the output is the ANSWER SECTION, which lists the resolved addresses and their TTL.

dig example.com

Reading the dig Answer Section

Each answer line shows: name TTL class type value.

  • TTL — seconds the record may be cached
  • type — A, AAAA, MX, CNAME, etc.
  • value — the resolved data

Use +short to strip everything except the value.

dig +short example.com

Querying Specific Record Types

Append the record type to look up anything besides an A record.

  • dig example.com MX — mail servers
  • dig example.com AAAA — IPv6
  • dig example.com TXT — text records (SPF, verification)
dig example.com MX

Choosing a Specific Resolver

Use @server to bypass your local resolver and ask a specific DNS server. This isolates whether your local cache is the problem.

Below queries Google Public DNS directly.

dig @8.8.8.8 example.com

Tracing the Resolution Path

dig +trace walks from the root servers down to the authoritative server, printing each delegation step.

This reveals broken delegations or stale glue records that a normal query hides.

dig +trace example.com

Reverse DNS Lookups

To map an IP back to a name, use -x. This queries the PTR record.

Missing PTR records often cause mail delivery and logging issues.

dig -x 8.8.8.8

Using nslookup Interactively

nslookup can run one-shot or interactively. In interactive mode you set type= and switch servers with server.

nslookup -type=MX example.com

Quick Answers with host

host gives compact output, ideal for quick checks.

  • host example.com — A and AAAA
  • host -t NS example.com — nameservers
host -t NS example.com

Interpreting Status Codes

The status field in the dig header is critical:

  • NOERROR — resolved fine
  • NXDOMAIN — name does not exist
  • SERVFAIL — server failed (often DNSSEC or upstream issues)

Checking the Local Resolver Config

Linux resolution settings live in /etc/resolv.conf and /etc/nsswitch.conf.

If dig works but applications fail, suspect nsswitch.conf ordering or a stale resolv.conf.

cat /etc/resolv.conf

Quick Check

Test your understanding of dig output.

Recap

You now diagnose DNS issues directly:

  • dig for flexible, scriptable lookups and +trace
  • @server to isolate resolver problems
  • -x for reverse lookups
  • Read status codes (NOERROR/NXDOMAIN/SERVFAIL)
  • Check /etc/resolv.conf and nsswitch.conf for local issues

These skills complement packet capture and firewall analysis for end-to-end troubleshooting.

Frequently asked questions

Is the “DNS Diagnostics with dig and nslookup” lesson free?

Yes — the full text of “DNS Diagnostics with dig and nslookup” is free to read here on the web, and the Linux Networking & TCP/IP for Developers course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Linux Networking & TCP/IP for Developers course, upgrade to CoddyKit PRO.

What will I learn in “DNS Diagnostics with dig and nslookup”?

Diagnose name-resolution problems on Linux using dig, nslookup, and host to inspect DNS records, trace resolution paths, and spot misconfigurations. You practise Linux Networking & TCP/IP for Developers with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Linux Networking & TCP/IP for Developers?

No prior experience is required. Linux Networking & TCP/IP for Developers on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “DNS Diagnostics with dig and nslookup” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Linux Networking & TCP/IP for Developers lesson?

Yes. Every Linux Networking & TCP/IP for Developers lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Packet Capture with Wireshark/tcpdump
  2. Network Performance Tools
  3. Linux Firewall (Netfilter/iptables)
  4. DNS Diagnostics with dig and nslookup
← Back to Linux Networking & TCP/IP for Developers