What is DNS poisoning?

DNS poisoning, also called DNS spoofing, plants a false answer in a resolver's cache, so users who ask for a name receive an address the attacker controls. Everyone relying on that resolver is redirected until the bad entry expires.

How does cache poisoning work?

A resolver that does not yet know an answer sends a query to an authoritative server and waits. If an attacker sends a forged reply that arrives first and matches the query's details, the resolver may accept and cache it. The forged answer then serves every client of that resolver for as long as its time to live, which the attacker can set high. Visitors type the right name and land on the wrong server, often a convincing copy of a login page.

What stops forged answers today?

Unpredictability, then cryptography. Resolvers choose random 16 bit query IDs and random source ports, so a forger must guess both, making blind attacks far harder than in the early days. Some resolvers also randomise letter case in the query name and check it in the reply. These measures raise the bar but do not prove an answer is genuine; DNSSEC does.

How does DNSSEC help?

It signs records. A zone owner publishes signatures alongside records, and a chain of trust runs from the root through the top-level domain to the zone. A validating resolver checks the signatures and rejects any answer that does not verify, so a forged record without the zone's private key is discarded. To benefit, the zone must be signed and the resolver must validate.

dig example.org A +dnssec +multi | grep -E 'RRSIG|flags'
delv @127.0.0.1 example.org A

The ad flag in dig output means a validating resolver checked the answer; delv performs the validation itself and reports the result.

AttackWhere it happensMain defence
Cache poisoningRecursive resolverRandomisation, DNSSEC validation
Local spoofing on a networkBetween device and resolverDNS over TLS or HTTPS, trusted networks
Domain or DNS account hijackRegistrar or DNS hostStrong authentication, registry lock
Changed resolver settingsInfected device or routerDevice security, fixed resolver config

Should I run a resolver on my server?

A local validating resolver is a good idea for servers that make many lookups, such as mail servers checking blocklists. Unbound is a common choice: it validates DNSSEC by default and caches answers locally. Make sure it answers only the server itself or your own tunnel network; an open resolver on the internet can be abused for amplification attacks and is itself a poisoning target.

server:
    interface: 127.0.0.1
    interface: ::1
    access-control: 127.0.0.0/8 allow
    access-control: 10.20.0.0/24 allow
    harden-glue: yes
    use-caps-for-id: yes
    auto-trust-anchor-file: "/var/lib/unbound/root.key"

How do I protect my own domains?

Sign the zone with DNSSEC at your DNS host and publish the DS record at the registrar. Protect the registrar and DNS host accounts with strong passwords and a second factor; most real redirections come from stolen account access rather than clever packet forgery. Consider a registry lock for critical domains, so changes to name servers need an out-of-band confirmation. Publish CAA records so only your chosen certificate authorities can issue certificates, which limits what an attacker can do even with a brief redirection.

How would I notice an attack?

Monitor your records from several outside resolvers and alert when an answer changes unexpectedly. Certificate transparency logs show every certificate issued for your names; a certificate you did not request is a strong warning sign. Users reporting certificate errors on your site are another signal worth taking seriously.

Does DNS over HTTPS stop poisoning?

It protects a different part of the path. DNS over HTTPS and DNS over TLS encrypt traffic between a device and its resolver, so nobody on the local network can read or forge answers in transit. They do not check whether the resolver itself was poisoned upstream; only DNSSEC validation does that. Use both: an encrypted connection to a resolver you trust, and a resolver that validates signatures.

How does HTTPS limit the damage?

A poisoned answer can send a user to the wrong address, but without a valid certificate for your name the browser warns loudly. That is why certificate issuance controls and HSTS matter: they turn a silent redirection into a visible error. How DNS works explains normal resolution, and Network security covers the wider defences.

Related pages

How DNS works

From a typed name to an IP address: resolvers, root and TLD servers, authoritative zones, record types, TTLs and caching, with the commands to watch it happen.

Read more

Network security

Layered network security for servers on the public internet: edge filtering, host firewalls, encrypted links, segmentation without a private network and watching traffic.

Read more

IPv6 and reverse DNS on your server

Configuring the IPv6 block that comes with every machine and setting the reverse DNS name of its IPv4 address from the console.

Read more

Mail server deliverability

Keep mail from your own server out of spam folders: DNS records, reverse DNS, sending limits and a clean outbound path.

Read more

Questions and answers

What is DNS poisoning?

Placing a forged answer in a resolver's cache so users asking for a name are sent to an address the attacker controls.

Does DNSSEC prevent DNS poisoning?

Yes, when the zone is signed and the resolver validates: forged records fail signature checks and are rejected.

Should I run an open DNS resolver on my server?

No. Limit a resolver to the server itself or your own networks; open resolvers are abused for amplification attacks.

How are most domains actually hijacked?

Through stolen registrar or DNS host credentials. Use strong passwords, a second factor and a registry lock.

How can I detect a DNS attack on my domain?

Monitor your records from several outside resolvers and watch certificate transparency logs for certificates you did not request.