DNS lookup: how to check any domain’s DNS records

Run a DNS lookup with dig, nslookup or PowerShell, read the answer and status, and check whether a DNS change is really live.

7–11 minutes
Laptop showing code next to a coffee mug

A DNSDNS The internet’s phone book. It turns a name people can remember, like example.com, into the number address computers use to find the server. More about DNS → lookup asks the Domain Name System what records a domain has, such as the IP address of its website or the servers that receive its email. This guide shows you how to run your own lookups on Windows, macOS and Linux, how to read the answers, and how to use them to check a DNS change or track down a fault.

To look up a domain’s DNS, run **nslookup example.com on any computer, or dig example.com on macOS and Linux. Add a record type to ask for something specific, such as dig example.com MX for mail servers, and add @ and a server** (for example dig @1.1.1.1 example.com) to choose who answers. To see the true, uncached answer, ask the domain’s own nameserverNameserver The server that holds all of a domain’s settings. Whoever runs your nameservers controls where your website and email point. More about Nameserver → directly.

What a DNS lookup actually is

Every domain has a list of DNS records, held on its nameservers. When your browser visits example.com, your device asks a resolver (a DNS server run by your internet provider, your company or a public service) for the domain’s A record. The resolver either answers from memory or asks the domain’s nameservers, then passes the answer back. How DNS works walks through that chain one step at a time.

A manual DNS lookup is you asking the same question, on purpose, with a tool that shows you the full answer. It is the first thing to try when:

  • a site has moved to a new host and you want to know where the domain really points
  • email is bouncing and you need to see the MX recordsMX record The domain setting that tells the world where to deliver your email. More about MX record →
  • a service asks you to add a TXT recordTXT record A domain setting that holds a line of text. Services use it to check you own the domain, and email uses it for SPF, DKIM and DMARC. More about TXT record → and you want to confirm it is live
  • a browser shows an error such as DNS_PROBE_FINISHED_NXDOMAIN

Two ideas make every result easier to understand:

  • CachedCache A saved copy of something, kept so it does not have to be made or fetched again. Like keeping a printed copy instead of reprinting it for every person who asks. More about Cache → versus authoritative. A resolver keeps answers for as long as their TTL allows. An authoritative nameserver is the one that holds the domain’s records, so it always gives the current answer. If the two disagree, you have just changed something and the old answer is still cached.
  • Which record you ask for. A lookup asks for one record type at a time. Asking for the A recordA record The line in a domain’s settings that says which server’s address to send visitors to. Like a forwarding address card for your website. More about A record → tells you nothing about MX or TXT records. The DNS record types guide explains what each one does.

The tools you already have

You do not need to install anything to make a basic lookup. Here is what each system includes.

ToolAvailable onBest for
nslookupWindows, macOS, LinuxQuick checks on any computer
Resolve-DnsNameWindows PowerShellDetailed lookups on Windows
digmacOS, LinuxFull answers, TTLs and troubleshooting
hostmacOS, LinuxShort, readable answers
Web lookup toolsAny browserChecking from outside your own network

On Linux servers, dig and host may not be installed by default. Install them with the package for your distribution.

On Ubuntu and Debian:

sudo apt update
sudo apt install dnsutils

On AlmaLinux, Rocky Linux and other Red Hat family systems:

sudo dnf install bind-utils

How to do a DNS lookup with dig

dig is the tool most administrators reach for because it shows exactly what the server said, including the TTLTTL How long other computers may remember a domain setting before checking again, in seconds. Short means changes show up faster. More about TTL → and the status of the reply.

Look up the website address

dig example.com

With no record type, dig asks for the A record. The important part of the output is the answer section:

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

Read it left to right: the name, the TTL in seconds (3600 is one hour), the class (IN means internet, and is always the same), the record type and the value. So example.com points to 203.0.113.10, and a resolver may keep that answer for up to an hour.

Ask for a specific record type

Put the type after the domain:

dig example.com AAAA
dig example.com MX
dig example.com TXT
dig example.com NS
dig www.example.com CNAME

NS shows the domain’s nameservers, which tells you which provider controls its DNS. That is often the first fact you need when an edit “does not work”: you may be editing records at a provider that is not in charge. The nameserver guide explains how that happens.

Get just the answer

For a short reply with only the values, add +short:

dig +short example.com MX
10 mail.example.com.

For the answer line with its TTL but none of the other sections, use +noall +answer:

dig +noall +answer example.com TXT

Choose which server answers

By default dig asks the resolver your computer is set to use. To ask a different one, put @ and its address first:

dig @1.1.1.1 example.com
dig @8.8.8.8 example.com

Those two addresses are public resolvers run by Cloudflare and Google. Asking them is a quick way to see what most of the internet is likely to be getting.

To see the real, current record, ask the domain’s own nameserver. Find it first, then query it:

dig +short example.com NS
dig @ns1.provider.net example.com

Replace ns1.provider.net with one of the names the first command returned. In the full output, look for aa in the flags: line. It stands for authoritative answer and confirms you are not reading a cached copy.

Follow the whole chain

+trace makes dig start at the root servers and follow each referral down to the answer, just as a resolver would, without using any cache:

dig +trace example.com

This is the best way to spot a problem at the registrarDomain registrar The company you buy and renew your domain name from, and where you choose who handles its settings. More about Domain registrar → level, such as nameservers that are set wrongly or a domain that is not delegated at all.

Reverse lookup

A reverse lookup turns an IP addressIP address The number address of a device on the internet, like 203.0.113.10. Computers use it to find each other, the way post uses street addresses. More about IP address → back into a hostname using a PTR record. It matters most for mail servers, because many receiving servers reject or distrust mail from an address with no reverse DNS.

dig -x 203.0.113.10

The PTR record is controlled by whoever owns the IP address, usually your hosting provider, not by your domain’s DNS. If it is missing or wrong, ask your host to set it.

How to do a DNS lookup with nslookup and PowerShell

nslookup

nslookup works the same way on every operating system:

nslookup example.com
nslookup -type=mx example.com
nslookup -type=txt example.com
nslookup example.com 1.1.1.1

The last line asks the resolver at 1.1.1.1 instead of your default one. When nslookup prints Non-authoritative answer, it means the reply came from a resolver’s cache rather than from the domain’s own nameserver. That is normal and not a fault.

Resolve-DnsName on Windows

PowerShell’s Resolve-DnsName gives clearer output than nslookup, including the TTL:

Resolve-DnsName example.com
Resolve-DnsName example.com -Type MX
Resolve-DnsName example.com -Type TXT -Server 8.8.8.8

Add -DnsOnly if you want to skip the local hosts file and other name sources, so you only see what DNS itself says.

Online DNS lookup and DNS checker tools

Web-based DNS checkers run the lookup from their own servers, often from many countries at once. They are useful in two situations:

  • After a change, to see whether resolvers around the world have picked up the new record. This is what people mean by checking DNS propagation.
  • When your own network may be the problem, for example an office firewallFirewall A gatekeeper that decides which connections are allowed into a server and blocks the rest. More about Firewall →, a VPN or a router that rewrites DNS answers. An outside check tells you what everyone else sees.

Keep in mind that a checker only shows what each of its resolvers has cached at that moment. A mix of old and new answers shortly after a change is expected, and clears as each cached copy reaches the end of its TTL. If the domain’s authoritative nameserver already returns the new value, the change is done and you are simply waiting.

Reading the result: status codes

The full dig output includes a status: value in the header. It tells you what kind of answer you got, which matters as much as the answer itself.

StatusMeaningWhat to check
NOERROR with an answerThe record existsCompare the value with what you expect
NOERROR with no answerThe name exists but has no record of that typeAdd the missing record, or ask for the right type
NXDOMAINThe name does not exist at allSpelling, subdomain records, domain registration and expiry
SERVFAILThe resolver could not get a usable answerNameservers down, wrong delegation, or a broken DNSSEC setup
REFUSEDThat server will not answer the questionYou queried a server that does not host the domain or does not allow outside queries

Common problems

SymptomCauseFix
Your lookup shows the new IP but the browser still loads the old siteYour browser or computer cached the old answerFlush your DNS cache and reopen the browser
Public resolvers show the old value, the authoritative nameserver shows the new oneCached copies have not expired yetWait for the old TTL to pass; lower the TTL before your next planned change
The authoritative nameserver still shows the old valueYou edited the zone at a provider that is not in chargeRun dig +short example.com NS and edit records at the provider it names
dig: command not found on a Linux serverThe DNS tools package is not installedInstall dnsutils (Ubuntu, Debian) or bind-utils (Red Hat family)
dig +trace stops before reaching your domainThe nameservers at the registrar are wrong or missingCorrect the nameservers in your registrar account
Results differ on office Wi-Fi and mobile dataThe office network uses its own resolver or filteringCompare with dig @1.1.1.1 and ask whoever runs the network

A quick routine for checking any DNS change

  • Find who controls DNS with dig +short example.com NS.
  • Ask one of those nameservers directly and confirm the new value with the aa flag set.
  • Ask two public resolvers, such as 1.1.1.1 and 8.8.8.8, to see what most visitors get.
  • Note the TTL in the answer so you know the longest you may have to wait.
  • Flush your own cache before testing in a browser.

If the authoritative answer is right, your part is finished. Everything after that is caches catching up.

Official documentation

Get the next guide

One email when there is something worth reading: new guides, errors going around, and hosting changes that affect your site.

No tracking pixels, and one click to leave.

Something out of date? Software changes. If a step no longer works, tell us and we will check it and update the page.