Lab 03: DNS Fundamentals
🎯 Objective
Understand how the Domain Name System (DNS) works by using dig, nslookup, and host to trace DNS resolution. Learn about DNS record types, the resolution chain, and how DNS-based attacks work conceptually.
📚 Background
DNS is often called the "phone book of the internet." When you type google.com in your browser, your computer doesn't know where Google's servers are — it asks DNS. DNS translates human-readable domain names into IP addresses that computers can route to.
The DNS resolution process is hierarchical: your computer asks a recursive resolver (usually your ISP or a public resolver like 8.8.8.8), which queries root nameservers (the 13 root server clusters), which point to TLD nameservers (for .com, .org, etc.), which point to authoritative nameservers for the specific domain. This process is called "recursive resolution."
DNS is a critical attack surface. DNS poisoning (cache poisoning) injects fake records into DNS resolvers, redirecting users to malicious sites. DNS exfiltration tunnels data through DNS queries (since DNS traffic often bypasses firewalls). DNS amplification uses UDP DNS responses to flood victims with traffic.
Understanding DNS records is essential: A records map names to IPv4, AAAA to IPv6, MX to mail servers, TXT for SPF/DKIM (email authentication), CNAME for aliases, and NS for nameservers.
⏱️ Estimated Time
35 minutes
📋 Prerequisites
Basic Linux command line
Docker with
innozverse-cybersecimage
🛠️ Tools Used
dig— DNS query tool (most powerful)nslookup— Interactive DNS lookuphost— Simple DNS resolutionpython3— DNS concept demonstrations
🔬 Lab Instructions
Step 1: Basic DNS Resolution with dig
dig (Domain Information Groper) is the gold standard tool for DNS queries.
📸 Verified Output:
💡 What this means: The
ANSWER SECTIONshowsgoogle.comresolves to142.251.34.142. The300is the TTL (Time To Live) in seconds — after 300 seconds, the cached record expires and must be re-queried.status: NOERRORmeans the query succeeded.SERVER: 8.8.8.8shows we're using Google's public DNS resolver.
Step 2: Short-form Query for Quick Lookups
For scripting and quick checks, +short strips the verbose output:
📸 Verified Output:
💡 What this means: Google has both IPv4 (A record) and IPv6 (AAAA record) addresses. The MX record
10 smtp.google.com.tells mail servers where to deliver email for@google.com. The10is the priority — lower numbers are preferred. If Google had multiple MX records, mail would try the lowest priority number first.
Step 3: Trace the Full DNS Resolution Chain
Watch DNS walk the hierarchy from root to authoritative nameserver:
📸 Verified Output:
💡 What this means: This shows the full resolution chain: (1) Root servers (
.) know about.comTLD servers. (2).comTLD servers (a.gtld-servers.net) know aboutgoogle.com's nameservers. (3) Google's nameservers (ns1.google.com) know the actual IP. This is why DNS poisoning is dangerous — if an attacker poisons any step in this chain, they can redirect traffic.
Step 4: Query Different DNS Record Types
📸 Verified Output:
💡 What this means: The SPF TXT record
v=spf1 include:_spf.google.com ~alltells receiving mail servers which IPs are authorized to send email for google.com — this helps prevent email spoofing. Reverse DNS (PTR) maps8.8.8.8back todns.google— useful for identifying server ownership and validating email sources.
Step 5: Use nslookup for Interactive DNS Queries
nslookup is available on every operating system and good for quick interactive queries:
📸 Verified Output:
💡 What this means: "Non-authoritative answer" means this result came from a cache (the resolver at 8.8.8.8) — not directly from Google's own nameservers. An authoritative answer would come directly from
ns1.google.com. For security investigations, you want authoritative answers to ensure you're not seeing stale/poisoned cached data.
Step 6: Query a Specific DNS Server
Sometimes you need to bypass your default DNS resolver — for example, to check if a domain is being blocked:
📸 Verified Output:
💡 What this means: All three resolvers return the same IP — the results are consistent. In an attack scenario, DNS poisoning would cause different resolvers to return different IPs. Security tools check multiple resolvers to detect inconsistencies. Comparing your ISP's DNS vs 8.8.8.8 vs the authoritative server can reveal DNS hijacking.
Step 7: DNS Attack Concepts — DNS Spoofing
Let's understand DNS spoofing without actually attacking anything:
📸 Verified Output:
💡 What this means: The 2008 Kaminsky Attack (named after security researcher Dan Kaminsky) exploited DNS to poison caches on a massive scale. The fix was to randomize the source port of DNS queries, making forged responses much harder to craft. Modern defenses include DNSSEC (cryptographic signing of records) and DNS over HTTPS.
Step 8: DNS Exfiltration Concept
DNS is often allowed through firewalls even when other traffic is blocked — attackers abuse this:
📸 Verified Output:
💡 What this means: Since many organizations allow DNS traffic outbound (without inspection), attackers tunnel stolen data through DNS queries. The attacker controls a nameserver that receives and logs these queries, then reassembles the stolen data. Tools like
dnscat2andiodineimplement DNS tunneling. Defense: use DNS filtering solutions and monitor for unusual query patterns.
Step 9: Check DNSSEC Validation
DNSSEC adds cryptographic signatures to DNS responses:
📸 Verified Output:
💡 What this means: The
adflag means "Authentic Data" — the resolver verified the DNSSEC signatures. TheRRSIGrecord is the cryptographic signature that protects theArecord from forgery. Google's results don't showadbecause they don't use DNSSEC on their main domain (ironically). Cloudflare does use DNSSEC.
Step 10: Build a DNS Reconnaissance Profile
In security assessments, DNS reconnaissance reveals a target's infrastructure:
📸 Verified Output:
💡 What this means: DNS reconnaissance is the first step in almost every penetration test. A DNS zone transfer (
AXFR) that succeeds is a critical vulnerability — it dumps ALL DNS records for a domain, revealing internal hostnames, IP ranges, mail servers, and more. Modern DNS servers should restrict zone transfers to authorized IP ranges only.
✅ Verification
📸 Verified Output:
🚨 Common Mistakes
Trusting DNS without DNSSEC: DNS responses can be forged unless DNSSEC validation is confirmed (
adflag in dig output)Ignoring TTL values: A very short TTL (1-60 seconds) can indicate fast-flux DNS used by malware command-and-control infrastructure
Zone transfer on production: Attempting zone transfers on systems you don't own is illegal; always get authorization first
📝 Summary
DNS translates domain names to IP addresses through a hierarchical chain: recursive resolver → root servers → TLD servers → authoritative nameservers
Different record types serve different purposes: A (IPv4), AAAA (IPv6), MX (mail), TXT (verification/SPF), NS (nameservers), PTR (reverse)
DNS is a rich attack surface: cache poisoning redirects users, DNS exfiltration tunnels data, DNS amplification enables DDoS
DNSSEC provides cryptographic protection against forged DNS responses
🔗 Further Reading
Last updated
