Skip to content

What Is DNS and How Does It Work

How the Domain Name System resolves a name: recursive resolvers, DNS records, DNSSEC, and how DNS differs from DHCP. The protocol explained for engineers.

Concept diagram explaining DNS: resolver, root & tld, authoritative, records.

The Domain Name System is an internet infrastructure protocol that translates human-readable domain names into the numeric IP addresses machines use to route traffic across networks. Every web request, email delivery, and API call starts with a Domain Name System (DNS) lookup, which means a misconfigured zone or a single resolver outage can take a domain offline regardless of whether the origin server is healthy. The protocol predates modern authentication standards, so its operational simplicity comes paired with a long catalog of well-documented threats, from cache poisoning to amplification floods. Operators who treat DNS as a fire-and-forget service learn the cost the first time a propagation delay collides with an expiring TLS certificate, or the first time a hijacked resolver redirects authentication traffic to an attacker-controlled host.

How DNS Resolution Works

The Domain Name System resolves a domain name through a four-step query chain: the recursive resolver, root nameservers, top-level domain nameservers, and authoritative nameservers each answer one layer before returning the IP address to the browser. The chain is hierarchical by design, and each hop hands off a narrower scope of authority. A browser does not talk to root servers directly; it talks to a recursive resolver (often run by an ISP, Google Public DNS at 8.8.8.8, or Cloudflare at 1.1.1.1) which carries out the full lookup on the client's behalf. The resolver checks its local DNS cache first, and only walks the chain when no fresh answer exists within the record's time to live (TTL) window. This caching layer absorbs the vast majority of global query volume and is the reason the public DNS system scales at all. A content delivery network applies the same idea to web content, caching pages and files close to visitors.

Flow diagram showing How DNS Resolution Works: root nameserver, TLD nameserver and IP returned to client
  1. The browser sends the query to a recursive resolver, which checks its DNS cache for a valid record.
  2. If the cache misses, the resolver queries a root nameserver, which responds with a referral to the correct top-level domain nameserver for the requested zone.
  3. The TLD nameserver (for example, the .com nameserver) returns a referral to the authoritative nameserver for the specific domain.
  4. The authoritative nameserver returns the A record IP address, the resolver caches it for the TTL duration, and the browser opens the connection.

The resolution path is governed by IETF RFC 1035, which still defines the wire format for queries and responses (see the RFC 1035 specification). A few terms recur throughout any DNS conversation, and getting them straight prevents most operational confusion.

Recursive resolver
A DNS server that performs the full lookup on behalf of a client, querying each layer of the hierarchy in turn. It returns the final answer to the requesting browser or application.
Authoritative nameserver
The server that holds the original DNS records for a zone. It returns definitive answers, not cached or relayed ones, and is the source of truth for a domain.
Time to live (TTL)
An integer in seconds attached to every DNS record that tells resolvers how long to cache the answer before re-querying the zone's nameserver.
DNS cache
The local store of recent query results held by a recursive resolver, operating system stub resolver, or browser. Cache hits skip the full chain and respond in microseconds.

DNS Record Types and Their Functions

The Domain Name System stores information in structured records (A, AAAA, CNAME, MX, TXT, and NS), each answering a different query type about a domain's addressing and routing. A zone file is a list of these records, and most operational DNS work amounts to editing one record at a time and waiting for caches to expire. The six record types below cover the overwhelming majority of production workloads; specialized types (SRV, CAA, DNSKEY, PTR) layer on top for service discovery, certificate authority pinning, DNSSEC signing, and reverse lookups respectively.

Record TypeMaps toExample use case
AIPv4 addressPoints example.com to 93.184.216.34 for browser traffic.
AAAAIPv6 addressPoints the same hostname to an IPv6 host such as 2606:2800:220:1::1.
CNAMECanonical hostname aliasAliases www.example.com to the apex domain so both resolve identically.
MXMail server hostnameRoutes inbound email for the domain to mail.example.com with a priority value.
TXTArbitrary text stringsHolds SPF policies, DKIM public keys, and domain-verification tokens for third-party services.
NSZone nameserver hostnameDelegates zone authority, for example pointing a subdomain at a separate zone nameserver.

The TTL field on each DNS record is the lever that controls propagation speed. Short TTLs (60 to 300 seconds) let operators reroute traffic quickly during a failover or a migration; long TTLs (24 hours or more) reduce query load on the zone's nameserver and shield the zone from amplification reflection. ICANN's reference material covers the registry and delegation model in more depth (see the ICANN DNS overview).

DNS Security: DNSSEC, Spoofing, and Amplification Attacks

The Domain Name System was not designed with authentication, making DNS spoofing (where an attacker injects false IP mappings into a resolver cache) and DNS amplification attacks among the most common infrastructure threats. NIST SP 800-81r2 codifies the deployment guidance most operators reference for DNSSEC signing, key rollover, and resolver hardening (see NIST SP 800-81r2). CISA has tracked active campaigns of DNS infrastructure tampering against government and enterprise registrars, and the alert remains the cleanest public reference for the attack pattern (see CISA Alert AA19-024A). DNS security is a layered problem, not a single switch, and the threats split into four operationally distinct categories.

Cloudflare DNS management interface showing DNS security configuration and threat protection settings
Credit: Cloudflare
  • DNS spoofing and cache poisoning. An attacker injects forged records into a resolver's DNS cache so future queries return attacker-controlled IPs. Mitigation: enable DNSSEC on the zone so resolvers can cryptographically verify record authenticity, and run a resolver implementation that randomizes source ports and query IDs.
  • DNS amplification DDoS. Attackers spoof a victim's source IP and send small queries to open resolvers that return large responses, reflecting amplified traffic at the target. Mitigation: deploy response rate limiting (RRL) on zone nameservers, close open resolvers to the public internet, and place CDN-layer filtering in front of authoritative infrastructure (see how CDNs protect against DNS attacks).
  • DNS hijacking via rogue resolvers. Malware or a compromised router silently rewrites the device's resolver to a hostile one. Mitigation: configure DNS-over-HTTPS (DoH) or DNS-over-TLS (DoT) on clients and internal resolvers so queries are encrypted in transit and pinned to a trusted endpoint.
  • Typosquatting and lookalike domains. Attackers register visually similar domains to intercept mistyped traffic or send phishing email. Mitigation: continuous domain monitoring for newly registered lookalikes plus a strict DMARC reject policy on the legitimate domain.

DNS vs DHCP: Different Layers, Complementary Roles

The Domain Name System and DHCP (Dynamic Host Configuration Protocol) operate at different layers: DNS translates names to addresses, while DHCP assigns IP addresses to devices before those addresses can be used. The two protocols are frequently confused because both deal with addressing, but their failure modes and operational concerns are independent. A device joining a network leases an IP address from a DHCP server, along with a subnet mask, default gateway, and the address of a DNS resolver. Only after that lease completes can the device send a DNS query to look up a hostname. The interplay matters when troubleshooting, since a working DNS resolver is useless to a client that never received a valid network address assignment, and a healthy DHCP lease is useless if the assigned resolver is unreachable (see IPv4 vs IPv6 implications for DNS).

DimensionDNSDHCP
What it resolvesTranslates domain names into IP addresses.Assigns IP addresses to devices on the network.
Protocol layer and portApplication layer, UDP and TCP port 53.Application layer, UDP ports 67 (server) and 68 (client).
Typical serverA DNS resolver such as an ISP resolver, Google 8.8.8.8, or Cloudflare 1.1.1.1.A DHCP server running on a router, firewall, or dedicated appliance.
Failure impactAll domain lookups fail; sites appear unreachable even though servers are healthy.Devices cannot obtain an IP address; the network appears completely offline.

Operators monitoring both services typically watch zone nameserver query rates for amplification anomalies, DHCP lease exhaustion for capacity planning, and resolver latency for end-user experience. A DNS security posture without DHCP visibility leaves a blind spot at the moment a device first joins the network, which is also when most rogue-resolver poisoning takes hold.

Frequently Asked Questions

What is DNS and why is it important?

The Domain Name System is the internet's naming infrastructure that maps human-readable hostnames to numeric addresses, making every web request, email delivery, and API call possible. Without DNS, users would need to remember the numeric address of every service they access. DNS failures cascade instantly: a misconfigured record or a resolver outage takes an entire domain offline regardless of whether the web server is healthy.

How does DNS work step by step?

A DNS lookup follows four steps from browser to answer. The browser queries the resolver, which checks its DNS cache; on a miss, the resolver queries a root nameserver, which points to the correct top-level domain nameserver; the TLD nameserver directs the resolver to the zone's nameserver for the domain; the zone's nameserver returns the A record address, which the resolver caches for the TTL duration before forwarding it to the browser.

What are the main differences between DNS and DHCP?

DNS translates domain names into numeric addresses, while DHCP dynamically assigns host addresses to devices on a network. DNS operates at the application layer and answers name queries; DHCP also operates at the application layer but runs a lease negotiation over UDP ports 67 and 68 to allocate a host address, subnet mask, gateway, and DNS server address to each device that joins the network. Both services must function correctly for a device to reach a website by name.

What are some common DNS security threats?

DNS faces four primary threats: cache poisoning, DNS amplification DDoS, DNS hijacking, and typosquatting. Cache poisoning injects false records into a resolver; DNS amplification uses open resolvers to flood targets with reflected traffic; DNS hijacking redirects queries to a rogue resolver; typosquatting registers lookalike domains to intercept mistyped traffic. DNSSEC, response rate limiting, and encrypted DNS transports address the first three; domain monitoring and DMARC policies address the fourth.

How can I secure my DNS?

Enable DNSSEC on your domain to cryptographically sign DNS records so resolvers can verify authenticity. Configure DNS-over-HTTPS (DoH) or DNS-over-TLS (DoT) on client devices and internal resolvers to prevent query interception in transit. Use a reputable resolver such as Google 8.8.8.8 or Cloudflare 1.1.1.1 that has response rate limiting enabled, rather than your ISP default. Set short TTL values on critical records so a poisoned cache entry expires quickly, and monitor your zone nameserver logs for anomalous query spikes that indicate amplification activity.

Share this guide

Amara Okeke

Amara Okeke covers cloud and web hosting for techshooked for the people who run sites and small infrastructure, from managed hosting and domain pricing to outages and the trade-offs between platforms. Coverage follows the full bill, including egress, support tiers and migration effort, and treats an outage as a story about root cause, recovery time and what customers were told along the way.