Computers connect to each other using IP addresses such as 192.0.2.10 (IPv4) or 2001:db8::10 (IPv6). People prefer names like example.com. The Domain Name System (DNS) is the global directory that translates one into the other — and when it fails, almost everything on a network appears broken.

What happens when you visit a website

When you type www.example.com into a browser, this is what happens behind the scenes:

  1. Local cache. Your browser and operating system check whether they already know the answer from a recent lookup.
  2. Recursive resolver. If not, your computer asks its configured DNS server — usually your router, your company's domain controller or a public resolver. This recursive resolver does the hard work on your behalf.
  3. Root servers. The resolver asks a root server where to find .com. The root server replies with the servers responsible for .com.
  4. TLD servers. The resolver asks a .com server, which replies with the authoritative name servers for example.com.
  5. Authoritative server. The resolver asks the authoritative server for www.example.com and receives the IP address.
  6. Answer and cache. The resolver returns the address to your computer, and both cache it for the length of the record's TTL.

This normally takes a few milliseconds, and most lookups are answered from a cache at step 1 or 2.

Common DNS record types

RecordPurposeExample value
AMaps a name to an IPv4 address192.0.2.10
AAAAMaps a name to an IPv6 address2001:db8::10
CNAMEMakes one name an alias of anotherwww → example.com
MXLists the mail servers for a domain, with priority10 mail.example.com
TXTFree text, used for SPF, DKIM, DMARC and domain verificationv=spf1 include:… -all
NSLists the authoritative name servers for a domainns1.example.net
SOAAdministrative details for a zone (primary server, serial number)—
PTRReverse lookup — maps an IP address back to a namemail.example.com
SRVLocates services such as Active Directory domain controllers_ldap._tcp.example.com

Testing DNS from the command line

Windows PowerShell

PowerShell
# Look up an A record
Resolve-DnsName example.com -Type A
 
# Look up mail servers
Resolve-DnsName example.com -Type MX
 
# Ask a specific DNS server, bypassing your configured one
Resolve-DnsName example.com -Server 1.1.1.1

Command Prompt (Windows, macOS, Linux)

nslookup is available almost everywhere:

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

Linux and macOS

dig gives the most detail. The +trace option shows every step from the root servers down:

Bash
dig example.com A
dig example.com MX +short
dig example.com +trace

Clearing the DNS cache

If a record was changed recently but your computer still uses the old address, clear the local cache:

CMD
ipconfig /flushdns

On Windows, ipconfig /displaydns shows what is currently cached.

When DNS is the problem

A quick test tells you whether DNS is the cause of a connectivity issue: if you can reach a server by IP address but not by name, DNS is at fault. Our network troubleshooting guide walks through that process step by step.