New

The new HostCloud is live. Web Hosting for ₹1 for your first month.

Web Hosting for ₹1 · first month

Claim offerClaim
Domains

How to check DNS records: A, CNAME, MX, TXT and NS lookups with dig and nslookup

Whether you are verifying a domain, debugging email or checking a migration, you need to read a domain's DNS records. Here are the exact commands, how to read the answers and what the common errors mean.

3 November 2026 · 9 min read
How to check DNS records: A, CNAME, MX, TXT and NS lookups with dig and nslookup

How to check DNS records: A, CNAME, MX, TXT and NS lookups with dig and nslookup

TL;DR: To check a DNS record, ask a DNS server for it. On Linux and macOS use dig example.com A, on Windows use nslookup -type=A example.com, or use an online lookup tool. Replace the record type with CNAME, MX, TXT or NS as needed. Add +short for a compact answer, and query a specific resolver, such as @8.8.8.8, to compare what different servers see. If the answer is empty, the record does not exist or has not spread yet. If you changed DNS recently, check the authoritative nameserver directly, because public resolvers may still show the old value.

What a DNS lookup does

DNS is the system that turns names into the data computers need: IP addresses for websites, mail servers for email and text records for verification. A lookup asks a DNS server for one kind of record for one name and shows the reply.

You might look up records to:

  • confirm a domain points to the right server after a migration,
  • check that a CNAME or TXT record was added correctly before verifying a service,
  • debug email problems by reading MX, SPF, DKIM and DMARC records,
  • see which nameservers control a domain, or
  • compare the answers different resolvers give.

If the record types are unfamiliar, our guide to DNS record types explains what each one is for.

The tools

dig is the standard tool on Linux and macOS, and available for Windows. It shows complete answers and details.

nslookup is available on Windows, Linux and macOS and is simpler.

host is a compact tool on Linux and macOS.

PowerShell on Windows has Resolve-DnsName.

Online lookup tools let you check records from a browser. These are handy if you do not have a terminal, and they query from their own servers, which shows how the world sees your records.

Looking up each record type

Replace example.com with your domain.

A record (IPv4 address):

dig example.com A +short
nslookup -type=A example.com

AAAA record (IPv6 address):

dig example.com AAAA +short

CNAME record (alias to another name):

dig www.example.com CNAME +short
nslookup -type=CNAME www.example.com

MX records (mail servers):

dig example.com MX +short

The numbers before each server are priorities. Lower numbers are tried first.

TXT records (SPF, verification, DKIM and DMARC):

dig example.com TXT +short
dig _dmarc.example.com TXT +short
dig google._domainkey.example.com TXT +short

NS records (nameservers):

dig example.com NS +short

SOA record (zone information):

dig example.com SOA +short

PTR record (reverse lookup of an IP address):

dig -x 203.0.113.10 +short

For more on PTR, see reverse DNS and PTR records.

On Windows PowerShell:

Resolve-DnsName example.com -Type MX

Table of DNS record types with the dig command used to look up each one: A, AAAA, CNAME, MX, TXT, NS, SOA and PTR

Reading the output

Without +short, dig prints a full response. The part you need is the answer section:

;; ANSWER SECTION:
example.com.    300    IN    A    203.0.113.10

From left to right: the name, the TTL in seconds, the class (almost always IN), the record type and the value.

  • TTL (time to live) is how long resolvers may cache the answer. A TTL of 300 means five minutes. It explains why changes seem to take time. Read how long DNS propagation takes for details.
  • Status appears near the top, for example status: NOERROR. This tells you whether the query worked.
  • Query time and server at the bottom show which resolver answered.

An answer section with no records but NOERROR means the name exists but has no record of that type.

Check the authoritative server

Public resolvers cache answers, so after a change they may show old data. To see the truth, ask the domain's own nameserver, the authoritative one.

  1. Find the nameservers:
dig example.com NS +short
  1. Ask one of them directly:
dig @ns1.example-dns.com example.com A +short

If the authoritative server returns the new value but a public resolver does not, you only have to wait for caches to expire. If the authoritative server returns the old value, the change was not saved correctly in your DNS panel.

To follow the whole chain from the root servers, use:

dig example.com +trace

This shows which servers delegate to which and is useful when nameserver changes at the registrar seem not to have taken effect.

Check a record from different resolvers

Different resolvers can give different answers during a change. Compare a few:

dig @8.8.8.8 example.com A +short
dig @1.1.1.1 example.com A +short
dig @9.9.9.9 example.com A +short

If they disagree, caches are still updating. Our guide on moving from GoDaddy to HostCloud and DNS propagation shows what to expect during a real migration.

Common lookup tasks

Verify a CNAME for a service. Look up the exact host the service gave you:

dig verify.example.com CNAME +short

The result should match the target the service asked for, including any trailing dot. If you see your domain repeated, such as verify.example.com.example.com, your DNS panel added the domain automatically. Enter only the host part.

Check SPF. Look at TXT records and find the one starting with v=spf1. A domain should have only one. See SPF records and lookup limits.

Check DKIM. Query selector._domainkey.example.com for TXT, or for CNAME on Microsoft 365. If you do not know the selector, read how to find your DKIM selector.

Check DMARC. Query _dmarc.example.com for TXT.

Confirm a site points to your host. Compare the A record with the IP address your host gave you, and check www as well. Our guide to pointing a domain to hosting covers the changes.

Find who hosts the DNS. Check the NS records. They tell you which provider's panel controls the zone, which is where changes must be made.

What common errors mean

Result Meaning
NXDOMAIN The name does not exist. Check spelling, expiry and that the record was added
NOERROR with empty answer The name exists, but there is no record of the type you asked for
SERVFAIL The resolver could not get a valid answer, often a broken delegation or DNSSEC problem
REFUSED The server declined to answer, for example because it is not authoritative or blocks the query
Timeout The server did not respond, so there may be a network or firewall issue
Old value from a public resolver Cached answer, wait for TTL to expire
Different values from different resolvers Propagation in progress

If a domain suddenly returns NXDOMAIN for everything, check whether it has expired, as explained in what happens when a domain expires. If you suspect DNSSEC, read DNSSEC explained.

FAQs

What is the best way to check DNS records?

Use dig on Linux or macOS or nslookup on Windows, and use an online tool if you do not have a terminal. Check the authoritative nameserver for the most accurate answer.

How do I look up a CNAME record?

Run dig www.example.com CNAME +short or nslookup -type=CNAME www.example.com.

Why does my DNS lookup show an old IP address?

Resolvers cache answers for the TTL. Wait for it to expire, or query the authoritative server to confirm the new value is saved.

What does NXDOMAIN mean?

The domain name does not exist, either because it is mistyped, expired or never registered, or because the specific subdomain has no records.

How do I check TXT records?

Run dig example.com TXT +short. SPF is the TXT record starting with v=spf1. For DMARC, query _dmarc.example.com.

Can I use a CNAME at the root domain?

Normally no. Standard DNS does not allow a CNAME alongside other records at the root, so use an A record, or an ALIAS or ANAME record if your DNS provider supports it.

How do I find a domain's nameservers?

Run dig example.com NS +short. The result shows which servers answer for the domain.

Are online DNS lookup tools reliable?

They are useful, but they query from their own servers and may use caches. Cross-check with a command-line lookup against the authoritative nameserver.

Conclusion

DNS lookups come down to one pattern: choose the record type, choose the server and read the answer. Use +short for quick checks, query the authoritative nameserver when you need the truth and compare resolvers when a change is still spreading. With those habits, most domain, email and migration problems can be diagnosed in minutes.

HostCloud's domain and DNS tools help you manage and verify your records. See https://hostcloud.in.

Sources:

Related posts