DNS — From Resolution to Tunneling, Cache Poisoning, and DoH-Driven Bypass

Manish Garg
Manish Garg Associate of (ISC)² · RingSafe
Apr 27, 2026
11 min read
Read as

Last updated: May 1, 2026

100% Free

No signup. No paywall. No catch. One of our 10 most-requested practitioner modules — published in full so anyone can learn for free. We earn through consulting, not by gating knowledge.

See all 10 free modules →

DNS is unauthenticated, mostly unencrypted, and the precondition for every connection on the Internet. This module walks through how a query actually resolves (recursive vs authoritative), the attack catalogue (cache poisoning, hijack, tunnelling, NXDOMAIN exfil), and the modern defences (DNSSEC where you can, DoT/DoH for transport privacy, RPZ + threat intelligence for blocking). Because every C2 channel and exfiltration path eventually touches DNS, defenders who instrument DNS catch more than defenders who instrument anything else.

DNS is the phonebook of the Internet but it is also a control plane, a sensor for every connection your hosts initiate, and one of the most-abused protocols in existence. This module is the practitioner-grade introduction: how queries actually resolve, the major attack classes and the real incidents that happened, and what to log so the SOC catches lateral movement and exfil before it matters.

How a DNS query actually resolves — the four-tier dance

You type ringsafe.in; your OS asks the configured stub resolver; the stub forwards to a recursive resolver (your ISP, 1.1.1.1, 8.8.8.8, or your corporate DNS); the recursive resolver, if it does not have a cached answer, asks the root (“who serves .in?”); root replies with NS records for .in; recursive asks .in TLD; .in replies with NS records for ringsafe.in; recursive asks ringsafe.in’s authoritative server; that server returns the A/AAAA records. Recursive caches the response per its TTL.

Why this matters for securityany intermediary in this chain can manipulate or observe the answer. Cache poisoning targets the recursive layer. Registrar/authoritative compromise (Sea Turtle, DNSpionage) targets the authoritative layer. Mass surveillance of users targets the recursive resolver — which is why DoH/DoT exist.

DNS record types — the dozen you must know

AIPv4 address.

AAAAIPv6 address.

CNAMEalias to another name (cannot coexist with other records at same label).

MXmail exchanger.

NSname server delegation.

SOAzone authority and refresh timing.

TXTarbitrary text — used for SPF, DKIM, domain ownership verification (Google, Microsoft, ACME challenges).

SRVservice location (Kerberos, SIP, _autodiscover).

CAAwhich CAs may issue certificates for this domain.

PTRreverse — IP to name.

DNSKEY / DS / RRSIG / NSEC / NSEC3DNSSEC.

HTTPS / SVCBmodern records that pre-announce TLS info, ALPN, ECH config; used for HTTPS upgrade and ECH bootstrap.

For SOCspikes in TXT or NULL queries are exfil/tunnelling indicators; spikes in NXDOMAIN are DGA (domain-generation-algorithm) malware indicators; sudden bursts of A queries to never-before-seen domains is C2 staging.

Cache poisoning — Kaminsky, birthday attacks, and modern descendants

In 2008 Dan Kaminsky disclosed the most impactful DNS attack ever: by spoofing UDP responses with guessed transaction IDs and matching source ports, an attacker could stuff false records into a recursive resolver’s cache, redirecting any user of that resolver. Mitigation was deployed globally within weeks: source port randomisation (16-bit entropy on top of the 16-bit transaction ID = 32 bits of guesswork). Modern descendants: SAD DNS (2020) leveraged ICMP rate-limit side-channels to leak source ports, partially defeating randomisation; patches followed.

Mitigation todayDNSSEC for cryptographic record integrity (still <20% adoption), DNS-over-TLS to a trusted resolver (eliminates spoofing on the client side), source-port entropy + 0x20 query-name randomisation on the recursive side. Cache poisoning is no longer trivial, but every recursive resolver should be hardened — defaults are mostly safe but explicit configuration audits matter.

DNS hijack — registrar and authoritative compromise

Sea Turtle (2017-2019) and DNSpionage (2018) campaigns by suspected state actors compromised registrars and authoritative DNS providers in MENA, Europe, and parts of Asia, pointing victim domains at attacker-controlled infrastructure for credential capture. The technique: get into a registrar console (often via reused credentials or weak SSO), change NS records, wait for caching to flush, harvest credentials over Let’s Encrypt-issued certs that the attacker now owns.

Defences for domain ownersregistrar account 2FA (FIDO2 hardware token preferred), registrar lock (a second-factor change requires written authorisation), DNSSEC (signed zones cannot be silently modified), CAA records limiting which CAs may issue (defeats Let’s-Encrypt-pivot if attacker controls DNS only), and CT log monitoring to detect rogue certs. Critical-infrastructure domains in India should also use the dotIN registry’s domain-lock feature.

DNS tunnelling — the C2 channel that hides in plain sight

DNS allows arbitrary text in TXT records and arbitrary names in queries. Malware encodes payload data into subdomain labels: aGVsbG8gd29ybGQ.attacker.example — the recursive resolver will faithfully forward that query to the attacker’s authoritative server, which replies with TXT records containing exfil ack or further commands.

Toolsdnscat2, iodine, DNS shell (Cobalt Strike).

Detectionhigh query rate to a single domain, long subdomain labels, base64-shaped patterns, high-entropy labels, NXDOMAIN bursts to non-existent labels. Zeek (formerly Bro) has battle-tested DNS scripts; commercial tools (Cisco Umbrella, Palo Alto DNS Security) bake this in.

The pragmatic minimumlog all DNS queries (ideally with response), look for outliers in label length, query rate per host, and entropy. Average legitimate DNS lookup is 15-30 chars; sudden bursts of 100+ char labels are the smoking gun.

DoT, DoH, and DoQ — the encryption story

Classic DNS over UDP/53 is plaintext; anyone on the path can observe and tamper. DNS-over-TLS (DoT) on TCP/853 wraps the query in TLS — easy to recognise on the wire by port, easy to block at the firewall if you want. DNS-over-HTTPS (DoH) on TCP/443 looks like ordinary web traffic — much harder to block without breaking general web traffic. DoQ (DNS-over-QUIC, RFC 9250) provides similar privacy with the latency benefits of QUIC. Browsers (Firefox, Chrome) ship DoH defaults; mobile OSes increasingly do.

Enterprise impactcorporate DNS-based filtering breaks unless you push policy to use your enterprise DoH endpoint. The 2026 best practice: deploy enterprise-controlled DoH/DoT (cloud-based via Umbrella/Cloudflare Gateway, or self-hosted unbound + dnsdist), block the well-known public DoH endpoints at the perimeter, monitor for unauthorised DoH attempts on TCP/443.

Defensive DNS — RPZ, threat intel, and what to log

Response Policy Zones (RPZ) let your recursive resolver enforce policy: “any query to known-malicious.com returns NXDOMAIN” or “queries to corporate-banned.com return our walled-garden IP”. RPZ feeds combine open-source (URLhaus, AlienVault OTX) and commercial threat intelligence (Spamhaus, Recorded Future, Cisco Talos).

Recommended loggingevery query with timestamp, client IP, query name, query type, response code, response time, response IPs. Volume is high (millions of queries/day per few thousand users) but it is the single highest-ROI security telemetry. Index it; alert on outliers; baseline legitimate behaviour per host.

Modern stackBIND or Unbound for resolver, dnsdist as a routing/policy front-end, RPZ feeds + threat-intel, Splunk/Elastic/Sentinel for analytics, Zeek for protocol-aware detection. Even a small SMB benefits from a basic RPZ — the cost of one PiHole + threatfeeds is negligible compared to the C2 it blocks.

Protective DNS — the highest-ROI security control most teams skip

Protective DNS (PDNS) means all corporate DNS resolution goes through a recursive resolver that enforces threat-intel-based blocking. Provided as a service: Cisco Umbrella, Cloudflare Gateway, Quad9, NextDNS for SMB. Self-hosted: Pi-hole + threatfeeds, Unbound + RPZ feeds.

What it blocksknown-malicious domains (C2, phishing, malware drops), DGA-pattern names, newly-registered domains with risky reputation, geo-blocked categories (gambling, adult, etc., per policy), DoH/DoT bypass attempts.

Why it worksmost attacks start with a DNS lookup. Block the lookup, prevent the connection.

What it does not catchattackers who know your PDNS provider and use IP-direct or compromised legitimate domains. PDNS is necessary, not sufficient.

Cost benchmarka small-to-medium Indian enterprise should expect to pay roughly ₹100-500 per user per year for managed PDNS; the prevented incidents pay for it many times over. For micro-businesses, NextDNS at low monthly fees is a serious upgrade over no protective layer at all.

DNS forensics — what the resolver logs tell you

A typical recursive resolver log line: ts=... client=10.0.0.5 query=portal.bank.example type=A response=NOERROR answer=192.0.2.10 ttl=300. Six fields you must keep: timestamp, client IP, query name, query type, response code, answer(s). With these, an analyst can reconstruct: “host X queried Y at time T and was told the answer was Z” — the precondition for almost every connection.

For investigationswhen a host is suspected compromised, pull its DNS history. Newly-seen domains, NXDOMAIN bursts, queries to TLDs you do not normally use, queries to typosquats of corporate brands — all flag for review.

Retention90 days minimum; ideally 1 year. The cost-of-storage is small relative to the forensic value.

Privacy under DPDPDNS logs are technically personal data when correlated with user-IP mappings. Document the legitimate purpose (security operations), apply access control, document retention, redact for non-IR access. Treat this as part of your DPDP-compliant data inventory.

DNS cache analysis — what to look for in your resolver logs

Your recursive resolver logs are an underused goldmine. Daily queries worth running:

1Top 50 queried domains — establishes the baseline; new entries get reviewed.
2Domains queried by exactly one host — outlier behaviour, often the first host to receive new malware.
3NXDOMAIN rate per host — sudden spikes are DGA or typo bursts.
4TXT-record query rate per host — high rates indicate tunnelling.
5Average query length per host — beaconing has predictable lengths; tunnelling has long high-entropy ones.
6Newly-registered domain queries — pair with a passive-DNS feed to identify domains <30 days old; correlate with phishing campaigns.
7Queries to top-level domains rarely used in your environment (.tk, .xyz, .top) — often the cheap real estate of malware. Tooling: any of these queries take 30 seconds in Splunk SPL or Elasticsearch DSL. Schedule the dashboard; review weekly; tune to your environment’s baseline.

DNS for the modern enterprise — the resolver design choice

A defensible enterprise DNS design in 2026 looks like this: split-horizon resolution, with internal authoritative servers serving private zones (corp.example.internal) accessed from the corporate network only, and external authoritative servers (preferably managed: Route 53, Cloudflare, NS1) serving the public domain.

Recursive layercorporate users → internal DoH/DoT-capable resolver (Unbound + dnsdist or managed Cloudflare Gateway / Umbrella) with RPZ feeds + threat intel.

External userspublic resolvers (1.1.1.1, 8.8.8.8) — out of your control.

Loggingevery resolver tier logs in a SIEM-ready format.

ValidationDNSSEC validation enabled at the recursive; signing on the authoritative for your public domains where the operational risk is acceptable.

Failoverevery authoritative service has at least four diverse authoritative servers across multiple networks.

Periodic testsimulate an authoritative outage and confirm your zone remains resolvable.

Diagrams

DNS resolution path — from your laptop to authoritative
  Stub (your OS)
   │  ringsafe.in?
   ▼
  Recursive resolver  (1.1.1.1 / corporate DNS)
   │
   │  ┌── (cache miss)
   ▼  ▼
  Root (.)
   │  "ask the .in TLD: x.x.x.x"
   ▼
  TLD .in
   │  "ask ringsafe.in NS: y.y.y.y"
   ▼
  Authoritative for ringsafe.in
   │  "A record = z.z.z.z, TTL 300"
   ▲
   │
  Recursive caches answer for TTL
   │
   ▼
  Stub (your OS)
DNS tunnelling — what the wire shows
Normal:
   client ──▶ recursive ──▶ authoritative
   query: "www.ringsafe.in?"  (15 chars)

Tunnelling:
   client ──▶ recursive ──▶ attacker.example NS
   query: "YWxsLW9mLW91ci1hY2Nlc3MtdG9rZW5z.attacker.example"
          (88 chars  · base64-shaped  · high entropy)

Detection patterns:
   • Sudden burst of long labels to one domain
   • >50% NXDOMAIN to a new SLD
   • Query rate per host 100× baseline
   • TXT-record responses dominate

References & deeper reading

FAQ

Is DNSSEC worth deploying?

On the signing side (your authoritative zone), yes — incremental cost, real benefit against hijack at the recursive layer. On the validating side (recursive resolver), already on by default at most modern resolvers. Operational caveat: DNSSEC misconfiguration takes you offline (.gov has done it twice). Use a managed DNS provider that handles signing for you (Route 53, Cloudflare, NS1) unless your team has explicit DNSSEC ops experience.

Can I trust public DoH resolvers (Cloudflare 1.1.1.1, Google 8.8.8.8)?

For privacy-from-ISP, yes. For corporate use, no — you lose telemetry and bypass enterprise filtering. The right enterprise pattern: corporate clients use a corporate DoH endpoint (your Cloudflare Gateway / Umbrella / NextDNS instance) so traffic stays observable while still being encrypted-on-wire.

How do I find out if my domain is being misused?

CT log monitoring (crt.sh, Cert Spotter) for unauthorised certs. PassiveDNS providers (DomainTools, RiskIQ, SecurityTrails) for anomalous resolution patterns. WHOIS monitoring for registrar changes. Brand-protection feeds for typosquats. For an Indian enterprise the baseline is CT + brand monitoring; everything else is incremental.

What is a DGA and why do SOCs care?

Domain Generation Algorithm — malware families generate hundreds of pseudo-random domains per day, register one or two with attacker-controlled NS, and use them as C2 fallback. NXDOMAIN bursts to deterministically-shaped names from the same host are a classic DGA fingerprint. The detection signal is well-suited to log-based ML; commercial DNS-security products bake it in.

What about DNS over Tor?

Adds latency and breaks corporate visibility. Mostly used by privacy-focused individuals; rarely seen in enterprise. If you see it on a corporate endpoint, treat it as a threat-hunting hit.

Should I run my own recursive DNS or use a public resolver?

Run your own (Unbound or BIND) for the corporate network: gives you logging, filtering, and visibility. For consumer-grade home use a public resolver (1.1.1.1, 9.9.9.9). The middle ground — corporate using Cloudflare Gateway / Umbrella — combines logging with threat intel.

What is a sinkhole and when do I use one?

A sinkhole DNS server returns a benign IP (often a security team-controlled box) for queries to known-malicious domains. The infected host connects to the sinkhole instead of the C2; the sinkhole logs everything. Useful for malware research and active incident response; integrate with PDNS feeds for sources of “known bad”.


⚖️ Legal: Use any techniques described here only on networks you own or have explicit written authorisation to test. In India, unauthorised access is punishable under IT Act §66 (up to 3 years + fine). Pair offensive testing with a signed Statement of Work / Rules of Engagement; pair forensic activity with §65B-aligned chain of custody.

Want this for your team?

Custom team training + practitioner advisory

Beyond the free academy — we run private workshops, vCISO advisory, and red-team exercises tailored to your stack. For Indian SMBs scaling past their first hire.

Book team training call Replies in 4 working hrs · India-only · Senior consultants