What Is a DNS Lookup and How Do You Perform One?
A DNS lookup is the process of querying a Domain Name System server to translate a human-readable hostname, such as example.com, into a machine-readable IP address. This foundational network request occurs billions of times every second, acting as the digital phonebook that connects your browser to the correct web server. Without DNS lookups, you would have to memorize complex numerical addresses for every website you wish to visit.
To quickly check the DNS records for any domain from your browser, you can use the XiaTools DNS Lookup tool, which queries global nameservers instantly without requiring command-line access.
Understanding How a DNS Lookup Works
When you type a URL into your address bar, your operating system, local router, and Internet Service Provider execute a carefully orchestrated multi-step resolution process. Understanding this workflow helps you troubleshoot website downtime, mail delivery failures, and propagation delays.
The Step-by-Step Resolution Process
- Browser Cache Check: Your browser checks its internal cache to see if it has visited the domain recently and remembers the associated IP address.
- Operating System Cache: If the browser cache misses, the OS checks its own local DNS cache.
- Recursive Resolver: If local caches fail, the query goes to your recursive resolver, typically managed by your ISP or a public provider like 1.1.1.1 or 8.8.8.8.
- Root Nameservers: If the resolver doesn't have the record cached, it asks one of the 13 global root nameservers, which directs it to the appropriate Top-Level Domain (TLD) nameserver (such as .com or .org).
- TLD Nameserver: The TLD server points the resolver to the authoritative nameservers responsible for the specific domain.
- Authoritative Nameserver: The authoritative server holds the actual record (like an A record pointing to
192.0.2.1) and returns it to the resolver, which caches it and hands it back to your device.
Common DNS Record Types
During a DNS lookup, you can request various record types depending on what information you need:
| Record Type | Purpose | Example Value |
|---|---|---|
| A | Maps a domain to an IPv4 address | 192.0.2.1 |
| AAAA | Maps a domain to an IPv6 address | 2001:db8::1 |
| CNAME | Aliases one domain name to another | ghs.google.com |
| MX | Specifies mail servers for email delivery | mail.example.com (Preference 10) |
| TXT | Holds text data for SPF, DKIM, and verification | v=spf1 include:_spf.example.com ~all |
| NS | Identifies authoritative nameservers for a zone | ns1.example.com |
How to Perform a DNS Lookup
Network administrators and developers rely on command-line utilities to perform DNS lookups directly against specific resolvers. This level of control allows you to bypass local caching and verify live records.
Using dig on Linux and macOS
The dig (Domain Information Groper) utility is the industry standard for querying DNS name servers.
To perform a basic A record lookup for a domain, open your terminal and run:
dig example.com
Sample output:
; <<>> DiG 9.10.6 <<>> example.com
;; global options: +cmd
;; Got answer:
;; -> \*\*Header\*\* opcode: QUERY, status: NOERROR, status: 3
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; QUESTION SECTION:
;; example.com. IN A
;; ANSWER SECTION:
example.com. IN A 192.0.2.1
;; Query status: response time: 14 ms
;; Query server: 192.0.2.53
If you want to query a specific nameserver, such as a public resolver, use the @ symbol:
dig @1.1.1.1 example.com TXT
Using PowerShell on Windows
Windows administrators use the Resolve-DnsName cmdlet in PowerShell to query domain records.
Resolve-DnsName -Name example.com -Type A
Sample output:
Name Type TTL Section IPAddress
---- ---- --- ------- ---------
example.com A 3600 Answer 192.0.2.1
To query MX records in PowerShell, update the type parameter:
Resolve-DnsName -Name example.com -Type MX
Using nslookup Across Platforms
nslookup works across Windows, macOS, and Linux for quick interactive or single-line queries:
nslookup -type=mx example.com
DNS Lookup Checklist for Troubleshooting
When a domain fails to resolve correctly, walk through this quick checklist to isolate the issue:
- Flush your local operating system DNS cache (
ipconfig /flushdnson Windows, orsudo dscacheutil -flushcacheon macOS). - Perform a direct query against an authoritative nameserver to bypass propagation lag.
- Verify that TTL (Time To Live) settings are appropriately low before making a planned IP migration.
- Check for syntax errors in TXT records, particularly SPF and DMARC strings.
- Confirm that your domain registrar points to the correct nameserver hostnames.
Common Mistakes and How to Fix Them
Mistake 1: Expecting Instant Global Propagation
When you update an A record at your DNS provider, users around the world may still see the old IP address. This happens because previous resolvers have cached the record based on its TTL value.
- The Fix: Lower your TTL to 300 seconds (5 minutes) at least 24 hours before making any planned server migration. Once the migration is complete, you can raise the TTL back to standard values like 86400 seconds (24 hours).
Mistake 2: Confusing CNAME and Apex Records
A common error is applying a CNAME record to a root domain (apex domain, such as example.com). DNS standards prevent apex domains from having CNAME records because they conflict with mandatory SOA and MX records.
- The Fix: Use standard A and AAAA records for your root domain, or utilize an alias/ANAME record feature if your DNS provider supports it. Reserve CNAME records exclusively for subdomains like
www.example.comorblog.example.com.
Mistake 3: Querying the Wrong Resolver During Testing
When troubleshooting an internal DNS change, testing through your default ISP resolver might return stale cached data.
- The Fix: Explicitly target public recursive resolvers like
8.8.8.8or1.1.1.1, or query the domain's authoritative nameservers directly using tools likedig @ns1.example.com example.com.