Module 12 · DNS-Based Detection Strategy

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

Last updated: April 29, 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 →

Why this module exists. Almost every internet attack starts with a DNS query — beaconing to C2, exfiltration via DNS tunneling, phishing-link resolution, malware updating itself. DNS logs are the highest-signal-per-byte log source in your environment, and most SOCs underuse them.

Why this module exists. Almost every internet attack starts with a DNS query — beaconing to C2, exfiltration via DNS tunneling, phishing-link resolution, malware updating itself. DNS logs are the highest-signal-per-byte log source in your environment, and most SOCs underuse them.

What DNS logs reveal

  • Beaconing — same source contacting same destination at fixed intervals
  • Tunneling — long, high-entropy subdomain queries to attacker-controlled domains
  • DGAs — algorithmic domain generation; queries to many random-looking domains in a burst
  • Newly-registered domains — phishing infrastructure often registered minutes before campaigns
  • Suspicious TLD usage — .top, .xyz, .tk see disproportionate malicious use
  • Failed lookups in clusters — malware testing for typosquats or fallback domains

Five high-fidelity DNS detections

1. DNS tunneling — query length anomaly

index=dns
| eval label_max = max(map(split(query, "."), len))
| where label_max > 40
| stats count by src_ip, query, label_max
| sort -count

Legitimate domain labels rarely exceed 30 characters. Tunneling encodes data in subdomain labels.

2. Beaconing — periodicity

# Group queries by src+domain; compute inter-arrival std-dev
index=dns
| stats values(_time) as times by src_ip, query
| eval intervals = mvmap(times, _time - lag(_time))
| where stdev(intervals) < 5 AND avg(intervals) BETWEEN 30 AND 600
# Flag domains queried at consistent 30s-10min intervals

3. Newly-registered domains

# Join DNS queries with WHOIS-derived registration date
index=dns
| eval domain = lower(query)
| lookup whois domain output registration_date
| where registration_date > _time - 7d
| stats count by src_ip, domain

NRDs are 100x more likely to be malicious than aged domains. Block at resolver or alert.

4. DGA detection — Shannon entropy

# Random-looking domain names have higher entropy
index=dns
| eval entropy = shannon_entropy(domain)
| where entropy > 3.5 AND length(domain) > 12
| stats count, dc(domain) as unique_domains by src_ip
| where unique_domains > 5

Sources making queries to many high-entropy domains in a short window = DGA candidate.

5. Suspicious TLD heatmap

index=dns
| eval tld = mvindex(split(query, "."), -1)
| stats count by tld
| where tld IN ("top", "xyz", "tk", "ml", "ga", "cf", "click")

Not all TLDs are malicious; ratios matter. .com is large and noisy. .top with significant traffic from your network is suspicious.

The threat-feed enrichment loop

Augment DNS detections with paid/free threat intel:

  • Free — DGArchive, Cisco Umbrella Top 1M (whitelist), MISP feeds, abuse.ch
  • Paid — Recorded Future, Mandiant, CrowdStrike Intel, RST Threat Feed
  • India-specific — CERT-In advisories, NCIIPC alerts

Workflow: every domain queried → enrich with threat-intel reputation → alert if score > threshold.

Where to collect DNS logs

  • Internal DNS resolvers — every Windows AD DNS server, every BIND/Unbound resolver. Highest fidelity.
  • Endpoint — Sysmon Event ID 22 (DnsQuery). Each process's DNS lookups attributed.
  • Cloud DNS — Route 53 Resolver Query Logs, Cloud DNS audit logs, Azure Private DNS logs.
  • Network — Zeek dns.log, passive DNS sensors.

Minimum: enable AD DNS audit logging + endpoint Sysmon. Layered: add Zeek at internet egress.

The DoH / encrypted DNS challenge

Browsers (Firefox, Chrome) increasingly default to DNS-over-HTTPS. Resolution bypasses your internal DNS resolver entirely. Bad for visibility; good for user privacy.

Defenders' options:

  • Block DoH endpoints at the firewall (Cloudflare 1.1.1.1, Google 8.8.8.8, NextDNS) — forces clients to use internal resolver.
  • Deploy Encrypted Client Hello (ECH) inspection on TLS-terminating proxies (limited).
  • Use endpoint Sysmon EID 22 — captures all DNS regardless of protocol.

Defender's checklist

  • DNS query logs from all internal resolvers ingested into SIEM.
  • Sysmon EID 22 on every endpoint.
  • Threat-intel enrichment on each query.
  • Block DoH at egress to force internal resolver.
  • Five detections above tuned and running.
  • NRD blocking at resolver level (RPZ) — prevents access to domains < 7 days old.
  • Quarterly DNS detection review — what attacks did we catch, what did we miss?
🧠
Check your understanding

Module Quiz · 6 questions

Pass with 80%+ to mark this module complete. Unlimited retries. Each question shows an explanation.

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