Dev & Security

Dig and nslookup: 7 Easy, Powerful DNS Checks

How to Use dig and nslookup to Troubleshoot DNS

Your website works for you but not for a client. Email bounces for no obvious reason. Your DNS panel says one thing, but browsers seem to believe another. When DNS gets confusing, two small command-line tools help inspect DNS responses: dig and nslookup.

This guide shows why they’re so useful, the basic commands for each, how to query specific nameservers, and how to read the output.

Why command-line DNS tools help

Your browser and operating system cache DNS answers, so what you see on screen may be minutes or hours old. Online checkers are helpful but limited. Command-line tools let you:

  • Query specific record types — A, AAAA, CNAME, MX, TXT, NS.
  • Ask a specific resolver, while remembering that the resolver may have its own cache.
  • Ask the authoritative nameserver directly to see what your zone really contains.
  • Compare answers in seconds when something doesn’t add up.

Windows includes nslookup. Availability of dig and nslookup on other systems depends on the installed packages; on Windows, dig can also be used in an appropriately configured WSL environment. Comfortable in a terminal? If not, read Terminal Basics Every Website Owner Should Know.

dig and nslookup: start with a dig query

  • dig example.com — the A record, with full details.
  • dig example.com +short — just the answer, perfect for quick checks.
  • dig example.com MX +short — mail servers and their priorities.
  • dig example.com TXT +short — SPF, verification, and other TXT records.
  • dig www.example.com CNAME +short — where an alias points.
  • dig example.com NS +short — which nameservers are responsible for the domain.

dig and nslookup on Windows

  • nslookup example.com — the IP address for a name.
  • nslookup -type=MX example.com — mail servers.
  • nslookup -type=TXT example.com — TXT records.
  • nslookup -type=NS example.com — nameservers.

The output is simpler than dig’s, which makes nslookup a good choice on Windows machines or when you’re guiding a client over the phone.

Querying specific nameservers

This is the real superpower. Add a server to your query:

  • dig @8.8.8.8 example.com +short — ask Google’s public resolver.
  • dig @1.1.1.1 example.com +short — ask Cloudflare’s resolver.
  • nslookup example.com 8.8.8.8 — the same idea with nslookup.
  • dig @ns1.yourdnsprovider.com example.com +short — ask the authoritative nameserver.

If the authoritative nameserver shows your new IP but public resolvers still show the old one, cached data may explain the difference; also verify delegation, all authoritative servers and the exact hostname — see DNS Propagation Explained: Why Changes Take Time. If the authoritative server shows the old value, the change was never saved, or you edited DNS at the wrong provider.

Reading the output like a pro

A full dig response has several sections. Focus on these:

  • status: NOERROR means no DNS error was reported; the requested record may still be absent. NXDOMAIN means the name doesn’t exist. SERVFAIL reports a resolution failure and needs investigation; DNSSEC is one possible cause.
  • ANSWER SECTION: the actual records, each with its TTL in seconds.
  • flags: aa (authoritative answer) means the reply came straight from the domain’s nameserver, not a cache.
  • Query time: the duration of that query; one result is not a reliable performance benchmark.

Need a refresher on what each record type means? Read DNS Record Types Explained: A, AAAA, CNAME, MX and TXT.

Key takeaways

  • dig and nslookup query any DNS record from your terminal.
  • Ask a specific resolver to bypass your local cache.
  • Compare public resolvers with your authoritative nameserver.
  • Status codes and TTLs tell you what’s really happening.

dig and nslookup: 7 essential checks

  1. Write the exact hostname and record type.
  2. Record the server used for the query.
  3. Read the complete response before shortening it.
  4. Compare a second resolver when needed.
  5. Check the relevant authoritative servers.
  6. Separate DNS results from application behavior.
  7. Keep a time-stamped troubleshooting note.

Use dig and nslookup as observation tools. The queries below inspect DNS data; they do not edit your zone or repair a website. Make a configuration change only after the evidence identifies what needs attention.

Prepare a reproducible lookup

Begin with one clear question. For a website, ask whether the exact public hostname returns the expected address. For mail routing, inspect the MX records for the receiving domain. For a verification problem, inspect the record type and name supplied by that service. A vague request to check the domain can mix unrelated records and make the output harder to interpret.

Replace the example domain with the domain you are authorized to investigate. Keep the spelling, subdomain and record type consistent across comparisons. When using dig and nslookup, a result for www.example.com is not a substitute for a result for example.com. Likewise, an A response does not tell you whether an AAAA record exists.

Write down the expected result and where it came from, such as the current hosting configuration. Do not assume that every address differing from an old screenshot is wrong. A proxy, CDN or managed platform may intentionally return a destination that differs from the origin server.

Match the command to the question

Choose the record type before using dig and nslookup
Question dig example nslookup example
IPv4 address dig example.com A nslookup -type=A example.com
IPv6 address dig example.com AAAA nslookup -type=AAAA example.com
Mail destination dig example.com MX nslookup -type=MX example.com
Text records dig example.com TXT nslookup -type=TXT example.com
Nameservers dig example.com NS nslookup -type=NS example.com

The commands are examples for systems with the relevant tools installed. Check the official Microsoft nslookup reference and the BIND manual pages for supported options. Keep the full output when a short answer leaves the cause unclear.

Read full answers from dig and nslookup

Dig and nslookup can present the same response differently. Preserve the original output from each tool when sharing evidence. Compare the question, answering server, status and answer records; a formatting difference between dig and nslookup is not by itself evidence that DNS changed.

Short output is useful when you already know what you expect, but it can hide context needed for diagnosis. Start with a complete response when an address is missing or a query fails. Read the status, the queried name, the record type and the server that answered. Then examine the returned records and any authority information.

An empty answer is not always the same as a nonexistent domain. The name may exist without a record of the requested type. For example, a domain can have mail records without returning the website address you expected. Dig and nslookup should be used to test a specific hypothesis, not to collapse every empty result into one explanation.

Preserve the output before trying another query. If you shorten it later, retain the original for support. A screenshot showing only an address can omit the resolver and record type, leaving another administrator unable to reproduce the observation.

Compare resolvers fairly

DNS propagation guide for comparing cached results

Query the same hostname and type through each server you are comparing. Keep the tests close together in time and note the results. Different caches may hold answers obtained at different moments. That can explain some differences after a change, but it is not the only possible explanation.

Dig and nslookup can direct a query to a selected resolver. That avoids relying on the browser’s own view of the lookup, but the selected resolver may still answer from its cache. A query to a public resolver should therefore not be described as guaranteed fresh authoritative data.

Be aware of the environment. A business network may use private DNS for internal names or route queries through its own infrastructure. Public resolvers may not know those internal names. Follow the organization’s network policy and do not disclose private hostnames to an external service merely to reproduce a tutorial.

Understand authoritative answers

Identify the authoritative provider with the nameservers guide

Before comparing answers, identify the active provider using our nameservers vs DNS records guide. An edit saved in an inactive zone will not change the answers served by the delegated nameservers.

The authoritative DNS service publishes the zone data for the name. Before querying it directly, establish which nameservers are active for the domain and which hostname you need to test. A control panel can contain a zone that is not currently authoritative. An edit there may have no effect on the public domain.

When multiple authoritative nameservers are involved, compare relevant answers rather than testing only one and assuming the entire service is consistent. If results differ unexpectedly, record each server and response. Dig and nslookup help collect that evidence, while the provider can help explain or correct the configuration.

A referral or another unexpected response may indicate that you asked a server that does not directly serve the requested data. Do not turn the first unfamiliar result into an immediate record edit. Read the complete output and confirm the delegation path with the appropriate documentation or support team.

Interpret TTL without treating it as a countdown for everyone

Understand TTL values when comparing resolver answers

For change planning, read TTL in DNS and safer change timing. Record the queried resolver and observation time so the displayed TTL has a clear context.

The TTL in a response describes a cache lifetime associated with that answer. A cached response can show a remaining lifetime that decreases over time. Other resolvers may have fetched the data at different moments, so their remaining values need not match.

For dig and nslookup investigations after a planned change, record the previous configured TTL as well as the current result. Lowering a value in the control panel does not retroactively shorten answers that caches already stored. Compare this behavior with the migration timeline before assuming a provider ignored the edit.

DNS cache duration is separate from cached web content. If the expected address is returned but the page still looks old, inspect the application, browser and any CDN. Repeating DNS edits will not necessarily refresh a cached image or rebuild a page.

Work through a website migration example

Imagine that a site moved to a new host and one colleague still sees the old page. First identify the exact hostname in the browser. Query its A and AAAA records as relevant, and compare the answers with the intended setup. Record whether a proxy is part of the design before comparing returned addresses with the origin server.

Use dig and nslookup to compare the local configured resolver with another permitted resolver, then inspect the authoritative information. If some answers still use the previous destination, compare the results with the old TTL and the time of the cutover. Preserve the old host during the planned transition where practical.

If the answers are correct, test the new server’s virtual host, certificate and application. A DNS lookup cannot prove that a database was copied or a contact form works. Keep resolution checks and application tests in separate columns of the migration record.

Work through an email routing example

If incoming mail fails after a provider change, inspect the receiving domain’s MX records. Compare the destinations with the exact values supplied for the current organization. Do not assume the website’s address must match the mail service. Website hosting and mail hosting can legitimately use different infrastructure.

Next, identify whether the reported problem concerns incoming mail, outgoing authentication or a specific application message. Dig and nslookup can inspect the relevant public records, but they cannot show every later delivery decision or mailbox rule. Use the sending provider’s error and event information alongside the DNS evidence.

For TXT-based verification, query the exact name required by the service. A verification record at a prefixed hostname is not the same as a TXT record at the domain root. Keep the supplied record name and type in your notes so a support team can see what was tested.

Handle errors methodically

For a timeout, record which server was queried and whether other permitted queries work from the same network. A timeout is not proof that the domain does not exist. For a resolution failure, compare the complete response and recent changes before deciding which configuration is responsible.

Dig and nslookup results can point toward a DNSSEC investigation, but a failure code alone does not establish the cause. Use a validation-aware diagnostic process and the provider’s support guidance. Avoid advising users to bypass security checks merely to make one test produce an address.

Change one relevant component at a time. Keep the previous value and a rollback plan before editing production DNS. Then repeat the same query and the relevant service test. Randomly changing several records can hide the cause and create new failures.

Keep a useful dig and nslookup support record

Include the exact command, the date and time, the answering server and the full response. Add the expected result and a short description of the user-visible symptom. State whether a hosting, nameserver or mail-provider change recently occurred. This gives support a concrete starting point.

Review the record before sharing it. Public DNS data may be appropriate for a provider ticket, while internal names and unrelated diagnostics may require restricted handling. Do not include account credentials or API keys. Dig and nslookup do not require those secrets for ordinary public record queries.

After the issue is fixed, record the successful result and the configuration change that resolved it. A clear history helps the next administrator distinguish a repeated problem from a new symptom. Keep it with the domain and hosting documentation rather than an isolated chat message.

Recommended domain and hosting option

Promotional recommendation: Consider KAWEDMA’s domain and hosting services if you need an implementation provider. Ask who will maintain the authoritative zone and which migration checks are included. For domain-based mailboxes, review its professional email service and confirm the setup scope.

Questions about dig and nslookup

Does one successful lookup prove the website works?

No. It confirms a DNS observation for that query. Test the destination service, HTTPS and important application functions separately.

Is short output always enough?

No. It can omit the context needed to distinguish an empty answer, a failure or an unexpected resolver. Preserve full output during diagnosis.

Should I benchmark providers with one lookup?

No. Cache state, network conditions and the chosen query affect the result. A single displayed time is an observation, not a reliable comparison of overall service quality.

Do dig and nslookup edit records?

The lookup commands in this guide inspect responses. Update DNS through the authorized management interface only after identifying the relevant configuration and preparing the change.

Use dig and nslookup during a support handover

When another person takes over the investigation, give them the original symptom and the smallest set of queries that reproduces it. Include a working comparison if one exists. Dig and nslookup output is more useful when the next administrator knows which part of the result was unexpected.

Keep observations separate from conclusions. For example, record that a named resolver returned the previous address at a particular time, then explain that cached data is one possible cause. Do not label that single observation as proof that the hosting provider failed. A precise record keeps the discussion focused on what can be verified.

Repeat dig and nslookup checks after the targeted fix

Use the same hostname, type and selected server as the original test. Then check the affected website or mail workflow. If both the DNS observation and the user-visible symptom improve, document that result. If only one changes, continue investigating the other layer instead of declaring the whole service repaired.

Finally, keep the successful configuration and the owner of each relevant account with your operational notes. Dig and nslookup can help with future diagnosis, but clear ownership determines who can make the necessary correction. Review access and support contacts when the team changes.

Practise dig and nslookup with a domain you control before an urgent migration. Familiarity with the output makes it easier to notice a misspelled hostname, a different record type or an unexpected answering server when a real problem occurs.

Z
zasma171

Writes for Hostreta about the topics covered in this article.

Comments (0)

Your email address will not be published. Required fields are marked *

Ad
Affiliate links
Tools we recommend
Protect Your Website with Automated Daily Backups
$2.09
Get it
the easiest way to manage all of your social media accounts
$29
Get it
Starter Website Get online, properly
$249
Get it
google workspace Business Starter
$3.75
Get it
Nord Vpn Cybersecurity. Built for Everyday Use
$8.99
Get it
More hosting options · affiliate
AI SiteBuilder
View plans
AI Application Hosting
View plans
Shared Hosting
View plans
Reseller Hosting
View plans
Managed WordPress · Rocket.net
View plans
Unmanaged VPS Hosting
View plans
Managed VPS Hosting
View plans
Virtual Dedicated Servers
View plans

We may earn a commission on purchases made through these links, at no extra cost to you.

Ad
Ad

$ top hosting picks

affiliate
★★★★★

KAWEDMA Website Services

See optionsCheck current plans and terms
  • Explore website setup services
  • Choose a scope that fits your project
  • Confirm features with KAWEDMA
Explore KAWEDMA →
affiliate link · we may earn a commission
★★★★★

Managed WordPress Hosting

See plansCurrent terms on provider website
  • Managed hosting for WordPress
  • Powered by Rocket.net
  • Compare current plan specifications
View WordPress plans →
affiliate link · we may earn a commission
★★★★★

AI SiteBuilder

See plansCheck current offer and renewal terms
  • Explore AI-assisted website creation
  • Review included tools and features
  • Choose a plan for your project
Explore SiteBuilder →
affiliate link · we may earn a commission

Never miss a new article

Join thousands of developers and builders getting a weekly digest of the best tech articles.