Skip to main content

Lesson 4 of 11

DNS Deep Dive & DNS Attacks

DNS (Domain Name System) is often called 'the phone book of the internet' - it translates domain names to IP addresses. Because DNS is fundamental and often trusted, it is a prime target for attackers and a critical monitoring point for defenders.

50 minBy Priygop Editorial TeamUpdated 2026Peer Reviewed & Verified

How DNS Resolution Works

How DNS Resolution Works
# DNS Resolution Flow (visiting google.com)

Browser checks local cache → not found
  ↓
OS checks /etc/hosts → not found
  ↓
Query sent to Recursive Resolver (ISP or 8.8.8.8)
  ↓
Resolver queries Root DNS Server (13 root servers globally)
  Root → "Ask the .com TLD nameserver"
  ↓
Resolver queries .com TLD nameserver
  TLD → "Ask google.com's authoritative nameserver"
  ↓
Resolver queries Google's authoritative nameserver
  Auth → "google.com = 142.250.80.46"
  ↓
Resolver caches result (TTL: Time To Live, e.g., 300 seconds)
Browser connects to 142.250.80.46

Critical DNS Record Types

  • A Record: Maps domain to IPv4 address - example.com → 93.184.216.34
  • AAAA Record: Maps domain to IPv6 address
  • MX Record: Specifies mail servers for a domain - critical for email security (SPF, DKIM, DMARC use DNS)
  • CNAME Record: Alias from one domain to another - misconfigured CNAMEs pointing to expired cloud resources lead to subdomain takeover attacks
  • TXT Record: Free-text records - used for SPF (email authentication), domain verification, DMARC policies
  • NS Record: Specifies authoritative nameservers - compromising NS records allows full DNS takeover
  • PTR Record: Reverse DNS - maps IP to hostname - used in spam blacklists and logging

DNS Attacks

  • DNS Cache Poisoning: Attacker injects malicious DNS records into a resolver's cache - users are redirected to attacker-controlled servers without knowing. Kaminsky Attack (2008) affected every major DNS resolver
  • DNS Amplification DDoS: Attacker sends small DNS queries with spoofed victim IP → open DNS resolvers send large responses to victim. Amplification factor up to 4,096x - 1 byte query generates 4KB response
  • DNS Tunneling: Encoding data inside DNS queries to exfiltrate data or tunnel C2 traffic through firewalls that allow DNS outbound. Attacker sets up authoritative server for evil.com; victim machines query sub.evil.com where sub encodes data
  • Subdomain Takeover: CNAME points to a cloud resource (e.g., AWS S3 bucket) that has been deleted. Attacker claims the resource - now controls the subdomain
  • DNS Hijacking: Attacker compromises router or ISP DNS settings - redirects all DNS queries through attacker-controlled resolver

DNS Security Defenses

DNS Security Defenses
# Practical DNS security commands

# 1. Investigate a domain with dig
dig example.com A          # A records (IPv4)
dig example.com MX         # Mail server records  
dig example.com TXT        # TXT records (SPF, DMARC)
dig example.com NS         # Nameserver records
dig -x 93.184.216.34       # Reverse DNS lookup

# 2. Check for DNS zone transfer vulnerability (information disclosure)
dig axfr @ns1.target.com target.com
# If this works, ALL DNS records are exposed - misconfiguration

# 3. Detect DNS tunneling (anomaly: long subdomains)
# Legitimate: api.example.com (short)
# Tunneled: 4f6c6d6f6e642d636f7270.evil.com (base64 encoded data in subdomain)

# 4. DNSSEC validation check
dig +dnssec example.com
# Look for 'ad' flag (Authenticated Data) - DNSSEC validated

# 5. Test your email security DNS records
dig example.com TXT | grep spf      # SPF: who can send email for this domain
dig _dmarc.example.com TXT          # DMARC: what to do with failed emails

Common Mistakes

  • Allowing recursive DNS queries from the internet on internal DNS servers - open resolvers are abused for amplification DDoS attacks
  • Not enabling DNSSEC - without cryptographic validation, DNS responses can be tampered with (cache poisoning)
  • Not monitoring DNS query logs - DNS tunneling is often only detectable through behavioral analysis of query patterns
  • Forgetting CNAME cleanup - leaving CNAMEs pointing to decommissioned cloud resources creates subdomain takeover opportunities

Tip

Tip

Practice DNS Deep Dive DNS Attacks in small, isolated examples before integrating into larger projects. Breaking concepts into small experiments builds genuine understanding faster than reading alone.

Diagram
Loading diagram…

The foundational security model: Confidentiality (privacy), Integrity (trust), and Availability (uptime).

Practice Task

Note

Practice Task - (1) Write a working example of DNS Deep Dive DNS Attacks from scratch without looking at notes. (2) Modify it to handle an edge case (empty input, null value, or error state). (3) Share your solution in the Priygop community for feedback.

Quick Quiz

Common Mistake

Warning

A common mistake with DNS Deep Dive DNS Attacks is skipping edge case testing - empty inputs, null values, and unexpected data types. Always validate boundary conditions to write robust, production-ready cybersecurity code.

Key Takeaways

  • DNS (Domain Name System) is often called 'the phone book of the internet' - it translates domain names to IP addresses.
  • A Record: Maps domain to IPv4 address - example.com → 93.184.216.34
  • AAAA Record: Maps domain to IPv6 address
  • MX Record: Specifies mail servers for a domain - critical for email security (SPF, DKIM, DMARC use DNS)

Hands-on Practice Tools for this Course

Test what you learn using these free in-browser developer utilities (no signup required).

All 40+ Tools

Topics in This Module

0/11 done