How to Do DNS Enumeration: Beginner's Guide to DNS Recon in Kali Linux
Learn how to do DNS enumeration step by step with dig, nslookup, dnsrecon and gobuster — a worked example, tool comparison and cheat sheet.
DNS as an Intelligence Goldmine
DNS enumeration is a methodology for extracting intelligence from the Domain Name System. Every domain publishes a wealth of data through its DNS records — IP addresses, mail servers, name servers, subdomains, and service configurations — that collectively map an organization's entire online infrastructure. Systematically querying these records reveals the hidden architecture behind any domain.
Prerequisites
Before studying DNS enumeration, you should understand:
What Is DNS Enumeration?
DNS enumeration is the process of systematically querying a domain's DNS records to discover its infrastructure: IP addresses, mail servers, name servers, subdomains, services, and security policies. It turns the public DNS directory into a map of the target's online footprint.
DNS enumeration splits into two styles. Passive DNS enumeration gathers records from third-party sources — certificate transparency logs, cached datasets, and search engines — without ever contacting the target's servers. Active DNS enumeration queries the target's name servers directly with dig, nslookup, zone-transfer attempts, and subdomain brute forcing. Passive work is silent and safe to start with; active work is faster and more complete, but it is visible to the target, so it belongs only in authorized testing.
How to Do DNS Enumeration in 5 Steps
Follow this workflow on every target. It takes the process from a single domain name to a full infrastructure map.
Step 1: Query Every Record Type
Start with the basics. Query A, AAAA, MX, NS, TXT, SOA, and CNAME records for the target domain with dig. Record everything — even an empty answer is intelligence (a domain with no MX record does not receive mail directly).
Step 2: Find the Authoritative Name Servers
Use dig +trace or query the NS records to identify the authoritative servers. Authoritative servers hold the complete zone data; recursive resolvers only return cached, possibly incomplete answers.
Step 3: Try a Zone Transfer
Attempt an AXFR zone transfer against each name server. Most servers refuse it, but a misconfigured one hands over the entire zone — every subdomain in a single query. Always test this first; it is the highest-value check in the whole workflow.
Step 4: Brute-Force Subdomains
Run gobuster or dnsrecon against a wordlist of common subdomain names. Watch for wildcard DNS, which makes every guess appear valid — verify any hit by checking whether random nonsense subdomains resolve to the same IP.
Step 5: Cross-Check with Certificate Transparency Logs
Query crt.sh for the domain. Every TLS certificate ever issued for the domain or its subdomains is logged there, and the log often reveals subdomains that brute forcing missed. Combine the two lists and remove duplicates.
DNS Record Types
| Record | Purpose | Example |
|---|---|---|
| A | IPv4 address | domain.com -> 192.0.2.1 |
| AAAA | IPv6 address | domain.com -> 2001:db8::1 |
| CNAME | Canonical name (alias) | www -> domain.com |
| MX | Mail exchange | domain.com -> mail.domain.com |
| NS | Name server | domain.com -> ns1.domain.com |
| TXT | Text records (SPF, DKIM) | v=spf1 include:_spf.google.com |
| SOA | Start of Authority | Zone metadata |
| SRV | Service location | _sip._tcp.domain.com |
| PTR | Reverse DNS (IP to name) | 192.0.2.1 -> host.domain.com |
| CAA | Certificate authority authorization | 0 issue "letsencrypt.org" |
| DS | Delegation signer (DNSSEC) | Key tag and digest |
| DNSKEY | DNSSEC public key | Zone signing key |
Basic DNS Queries with dig and nslookup
Using dig
# Basic A record lookup
dig example.com
# Short answer only
dig example.com +short
# Query specific record type
dig example.com MX +short
dig example.com NS +short
dig example.com TXT +short
dig example.com SOA
# Query specific DNS server
dig @8.8.8.8 example.com
# Trace DNS resolution path
dig example.com +trace
# Reverse DNS lookup
dig -x 93.184.216.34
Reading dig Output
A normal dig answer has three useful sections. The ANSWER SECTION holds the records you asked for. The AUTHORITY SECTION names the servers responsible for the zone. The ADDITIONAL SECTION carries extra records, usually the IP addresses of the name servers. When a query returns no ANSWER SECTION, check the status line: NOERROR with zero answers means the record type genuinely does not exist, while SERVFAIL or REFUSED means the server would not answer at all.
Using nslookup
# Basic lookup
nslookup example.com
# Query specific record type
nslookup -type=MX example.com
nslookup -type=NS example.com
nslookup -type=TXT example.com
nslookup -type=SOA example.com
# Query a specific server
nslookup example.com 8.8.8.8
Using host
The host command is the simplest of the three — one line per answer, easy to pipe into scripts:
# Basic lookup
host example.com
# Query specific record type
host -t mx example.com
host -t ns example.com
host -t txt example.com
# Reverse lookup
host 93.184.216.34
A Note on ANY Queries
dig example.com ANY used to return every record type in one query. Most public resolvers now refuse or truncate ANY queries because they were abused for DNS amplification attacks. Query each record type separately instead — it is slower, but it works everywhere.
Worked Example: Mapping example.com from Scratch
This example uses example.com, a domain reserved for documentation by IANA. All outputs below are illustrative — run the commands yourself to see the live values.
Step 1: The A Record and Name Servers
$ dig example.com +short
93.184.216.34
$ dig example.com NS +short
a.iana-servers.net.
b.iana-servers.net.
$ dig example.com AAAA +short
2606:2800:220:1:248:1893:25c8:1946
One IP address, two name servers, one IPv6 address. Already the shape of the infrastructure is visible: a single-hosted site on IANA's name servers.
Step 2: Mail and Text Records
$ dig example.com MX +short
# (no output — example.com publishes no MX record)
$ dig example.com TXT +short
# (no output — example.com publishes no TXT record)
Empty answers are still answers. No MX record means the domain does not receive mail directly. No TXT record means there is no SPF, DKIM, or DMARC policy to read. On a real target, these two queries often reveal the mail provider, the email security posture, and third-party services in use.
Step 3: Trace the Resolution Path
$ dig example.com +trace
# dig walks the chain: root servers -> .com servers -> a.iana-servers.net
# The final answer comes from the authoritative server, not a cache.
The trace confirms which servers are authoritative for the zone. Those are the servers you target for the zone-transfer attempt in the next step.
Step 4: Try a Zone Transfer
$ dig @a.iana-servers.net example.com AXFR
; Transfer failed.
$ dnsrecon -d example.com -t axfr
# dnsrecon reports the transfer as refused on both name servers.
The transfer is refused, as it should be on a properly configured server. A successful AXFR here would have listed every record in the zone — the entire subdomain list in one response. The refusal itself is a useful finding: the zone is not leaking.
Step 5: Brute-Force Subdomains
$ gobuster dns -d example.com -w /usr/share/wordlists/dns/subdomains-top1million-5000.txt
# Found: www.example.com
# (illustrative — on a real target this list is usually much longer)
Step 6: Cross-Check Certificate Transparency
$ curl -s "https://crt.sh/?q=%25.example.com&output=json" | jq -r '.[].name_value' | sort -u
example.com
www.example.com
The certificate log agrees with the brute-force result. When the two sources disagree, investigate the extra names — CT logs often reveal subdomains that wordlists miss, including staging and internal names that were once given certificates.
Zone Transfers (AXFR)
A zone transfer replicates an entire DNS zone from a primary server to a secondary server. The AXFR request asks for everything: every A, MX, TXT, and subdomain record in one response. Secondary servers need this to stay in sync, so the protocol itself is legitimate — the vulnerability is a server that answers AXFR requests from anyone.
Misconfigured servers allow anyone to request a copy of the DNS zone:
# Find name servers
dig example.com NS +short
# Attempt zone transfer from each NS
dig @a.iana-servers.net example.com AXFR
# Using dnsrecon
dnsrecon -d example.com -t axfr
A refused transfer returns "; Transfer failed." A successful transfer dumps the whole zone. Because a single successful AXFR replaces hours of brute forcing, test every name server for it before doing anything else.
Subdomain Brute Forcing
Choosing a Wordlist
Kali ships SecLists wordlists under /usr/share/wordlists/dns/. Start small and grow only if the target justifies it:
| Wordlist | Entries | Use when |
|---|---|---|
| subdomains-top1million-5000.txt | 5,000 | First pass on any target |
| subdomains-top1million-20000.txt | 20,000 | Deeper pass after the first |
| subdomains-top1million-110000.txt | 110,000 | Thorough pass on a large target |
| dns-Jhaddix.txt | ~200,000 | Maximum coverage, slow |
Brute Forcing Commands
# Using dnsrecon
dnsrecon -d example.com -D /usr/share/wordlists/dns/subdomains-top1million-20000.txt -t brt
# Using gobuster (fastest option)
gobuster dns -d example.com -w /usr/share/wordlists/dns/subdomains-top1million-5000.txt
# Using ffuf (HTTP-based subdomain discovery)
ffuf -w /usr/share/wordlists/dns/subdomains.txt:HOST -u http://FUZZ.example.com -fc 400,404,403
The Wildcard Trap
A wildcard record (*.example.com) matches any subdomain not explicitly defined. This causes brute forcing tools to return false positives since every query appears valid. Verify findings by checking if multiple random subdomains all resolve to the same IP:
# If all three resolve to the same IP, the zone uses a wildcard
dig random12345.example.com +short
dig nonsense98765.example.com +short
dig qwertyuiop.example.com +short
If a wildcard is present, filter results to only the subdomains that resolve to a DIFFERENT address, or switch to passive sources (CT logs, datasets) that do not depend on live resolution.
Certificate Transparency Logs
# Using crt.sh to find subdomains
curl -s "https://crt.sh/?q=%25.example.com&output=json" | jq -r '.[].name_value' | sort -u
Certificate Transparency logs record every TLS certificate issued by public certificate authorities, including subdomains. This passive technique reveals subdomains without directly querying the target's DNS infrastructure, making it ideal for stealthy reconnaissance. It also catches names that wordlists never contain — staging systems, internal tools, and one-off project subdomains that were given a certificate once and forgotten.
DNS Enumeration Tools Compared
| Tool | Best for | Key flags |
|---|---|---|
| dig | Individual queries, scripting | +short, +trace, @server, -x |
| nslookup | Quick interactive lookups | -type=MX/NS/TXT/SOA |
| host | Simple one-line answers | -t mx/ns/txt, reverse lookup |
| dnsrecon | All-in-one scanning | -t axfr/brt/srv/zonewalk, -D wordlist |
| dnsenum | Comprehensive probing | -f wordlist, --noreverse |
| fierce | Subdomain discovery | --domain, --subdomains |
| gobuster | Fast DNS brute forcing | dns -d domain -w wordlist |
| ffuf | HTTP-based subdomain fuzzing | -w wordlist:HOST -u http://FUZZ.domain |
| subfinder | Passive subdomain discovery | -d domain, -all |
| amass | Deep passive + active enum | enum -d domain |
| theHarvester | OSINT aggregation | -d domain -b crtsh |
| massdns | High-speed bulk resolution | -r resolvers.txt -t A -w out.txt |
dig, nslookup, host, dnsrecon, dnsenum, fierce, gobuster, ffuf, subfinder, amass, and theHarvester are all available in Kali Linux. massdns is a separate high-speed resolver for bulk work — useful when you need to resolve hundreds of thousands of names quickly.
DNS Enumeration with Nmap
Nmap ships DNS enumeration scripts that fit naturally into a wider port scan:
# Brute-force subdomains with Nmap
nmap --script dns-brute example.com
# Attempt a zone transfer against a name server
nmap -p 53 --script dns-zone-transfer --script-args dns-zone-transfer.domain=example.com a.iana-servers.net
# Enumerate SRV records
nmap --script dns-srv-enum example.com
The dns-brute script is slower than gobuster but useful when Nmap is already running against the target. The dns-zone-transfer script automates the AXFR check against every name server Nmap finds.
Automated DNS Enumeration Tools
dnsrecon
# Comprehensive DNS reconnaissance
dnsrecon -d example.com
# Zone transfer test
dnsrecon -d example.com -t axfr
# Subdomain brute force
dnsrecon -d example.com -D subdomains.txt -t brt
# SRV record enumeration
dnsrecon -d example.com -t srv
# DNSSEC zone walking
dnsrecon -d example.com -t zonewalk
dnsenum
# Full DNS enumeration
dnsenum example.com
# With custom wordlist
dnsenum -f /usr/share/wordlists/dns/subdomains.txt example.com
fierce
# Discover subdomains and test zone transfers
fierce --domain example.com
# With a wordlist
fierce --domain example.com --subdomains /usr/share/wordlists/dns/subdomains-top1million-5000.txt
Security Assessment via DNS
Email Security Checks
# Check for DMARC policy
dig _dmarc.example.com TXT +short
# Check SPF record
dig example.com TXT +short | grep "v=spf1"
# Check for DKIM
dig default._domainkey.example.com TXT +short
A missing DMARC policy means the domain's mail can be spoofed more easily — a finding worth reporting. A strict policy (p=reject) means the domain owner has hardened email authentication. SPF tells you which servers may send mail for the domain; DKIM selectors reveal the mail provider.
DNSSEC and Zone Walking
DNSSEC zone walking exploits NSEC records in DNSSEC-signed zones to enumerate all domains. NSEC records prove non-existence of a domain but inadvertently list the next existing domain, allowing complete zone enumeration. Query one name, read the NSEC record for the next name, and repeat until the zone is mapped.
NSEC3 was designed to stop this: it hashes the names, so the chain reveals hashes instead of readable domain names. Zone walking still works in theory against NSEC3, but it requires cracking the hashes, which is slow. Test for it with dnsrecon:
dnsrecon -d example.com -t zonewalk
If the zone uses plain NSEC, the walk returns the full name list. If it uses NSEC3, note it as a hardening finding and move on.
Passive vs Active DNS Enumeration
| Aspect | Passive | Active |
|---|---|---|
| Sources | CT logs, datasets, search engines | Direct queries, AXFR, brute forcing |
| Touches target servers? | No | Yes |
| Detectable by target? | No | Yes — queries appear in server logs |
| Speed | Fast (pre-collected data) | Slower (live queries, rate limits) |
| Completeness | Misses unlisted names | Finds live names wordlists contain |
| Best for | First pass, stealth, scoping | Confirmation, depth, live verification |
Start passive, then go active. The passive pass tells you what exists in public records; the active pass confirms what is live right now and fills the gaps the logs missed.
What DNS Enumeration Reveals
Attack Surface Mapping
# Discover cloud-hosted services
dig example.com CNAME +short | grep -E "cloudfront|aws|azure|google|cloudflare"
# Identify third-party services via MX records
dig example.com MX +short | awk '{print $NF}' | sort -u
CNAME records pointing at cloud providers reveal where the target hosts its services. MX records reveal the mail provider and any third-party email services. TXT records reveal verification tokens for services the target uses. Together, the records sketch the target's vendor list — and every vendor is another place to look for exposed assets.
DNS Enumeration Cheat Sheet
Commands
| Command | Purpose |
|---|---|
| dig example.com +short | Quick A record lookup |
| dig example.com MX/NS/TXT/SOA +short | Query one record type |
| dig @8.8.8.8 example.com | Query a specific resolver |
| dig example.com +trace | Walk the resolution chain |
| dig -x 93.184.216.34 | Reverse lookup an IP |
| nslookup example.com | Basic lookup |
| nslookup -type=MX example.com | MX record via nslookup |
| host example.com | One-line lookup |
| host -t mx example.com | MX record via host |
| dig @ns1.example.com example.com AXFR | Zone transfer attempt |
| dnsrecon -d example.com | Full automated scan |
| dnsrecon -d example.com -t axfr | Zone transfer test |
| dnsrecon -d example.com -t brt -D wordlist | Subdomain brute force |
| dnsenum example.com | Comprehensive probing |
| fierce --domain example.com | Subdomain discovery + AXFR test |
| gobuster dns -d example.com -w wordlist | Fast DNS brute forcing |
| nmap --script dns-brute example.com | Nmap subdomain brute force |
| curl crt.sh query + jq | Certificate transparency lookup |
| dig _dmarc.example.com TXT +short | DMARC policy check |
Record Types at a Glance
| Record | Reveals |
|---|---|
| A / AAAA | Server IP addresses |
| MX | Mail provider and mail servers |
| NS | Name servers and DNS provider |
| TXT | SPF/DKIM/DMARC, verification tokens |
| SOA | Zone admin and serial |
| CNAME | Aliases and cloud services |
| SRV | Services and their ports |
| PTR | Reverse mapping, hostnames |
| CAA | Which CAs may issue certificates |
| DS / DNSKEY | DNSSEC deployment |
Troubleshooting DNS Enumeration Problems
| Problem | Likely cause | Fix |
|---|---|---|
| dig returns no answer (NOERROR, 0 answers) | The record type does not exist for the domain | Try other record types; an empty answer is still a finding |
| dig returns SERVFAIL | Resolver or server error, often DNSSEC validation failure | Query the authoritative server directly with @ns |
| Zone transfer refused | Server is correctly configured | Note it as a hardening finding and move to brute forcing |
| Every brute-force guess resolves | Wildcard DNS record in the zone | Verify with random subdomains; filter to non-wildcard IPs |
| Brute force finds nothing | Wordlist too small or subdomains use unusual names | Try a larger wordlist, then CT logs and datasets |
| Scans are very slow | Rate limiting or a huge wordlist | Reduce threads, use a smaller wordlist, resolve with massdns |
| crt.sh returns too many results | Certificates for many subdomains over years | Filter by date and de-duplicate with sort -u |
| dig +trace times out | Firewall blocks outbound DNS or trace queries | Use a public resolver (@8.8.8.8) instead of tracing |
| DNS over HTTPS hides queries | The target uses DoH/DoT resolvers | Use passive sources; active queries still work via the resolver |
Common Mistakes
Not checking all record types: MX, TXT, and SRV records reveal infrastructure not visible in A records.
Assuming zone transfers are always blocked: Some servers still allow AXFR.
Ignoring wildcard records: *.example.com can make brute forcing find false positives.
Forgetting IPv6: AAAA records may expose additional attack surface.
Trusting a single tool: One tool's wordlist or data source always misses names. Combine dig, gobuster, dnsrecon, and crt.sh.
Skipping the email security checks: SPF, DKIM, and DMARC records reveal the mail provider and the domain's spoofing resistance in seconds.
Recording nothing: Enumeration produces dozens of findings. Write them down as you go — IPs, names, providers — or the map falls apart.
Best Practices
Is DNS Enumeration Legal?
Querying public DNS records is legal — DNS is a public directory by design, and anyone can ask a name server for a domain's records. What matters is scope and intent. Enumerate only domains you own or have written permission to test, and use the results for defense, research, or authorized assessment — never to attack the target. Aggressive brute forcing or repeated zone-transfer attempts against someone else's infrastructure without permission can cross into unauthorized testing, even though each individual query is harmless.
Summary
DNS enumeration reveals an organization's online infrastructure. Key techniques include querying all record types, attempting zone transfers, brute forcing subdomains, and leveraging certificate transparency logs. Automated tools like dnsrecon streamline the process. Start passive with certificate logs, go active with dig and gobuster only on authorized targets, and always check the email security records — the whole map usually takes less than an hour to build.
Knowledge Check
Answers: 1. An AXFR request that copies the entire zone; it reveals every subdomain at once. 2. NSEC records list the next existing name, so walking the chain maps the zone. 3. A wildcard matches any undefined subdomain, making brute forcing return false positives. 4. Authoritative servers hold complete zone data; recursive resolvers return cached, possibly incomplete answers. 5. SPF policies, DKIM keys, DMARC policies, verification tokens, and third-party services. 6. Query all record types, find authoritative servers, try a zone transfer, brute-force subdomains, cross-check CT logs. 7. Query several random subdomains — if they all resolve to the same IP, a wildcard is present. 8. Passive uses third-party sources without touching the target; active queries the target's servers directly.
Keep Learning
Frequently Asked Questions
Continue Learning
Attack Surface Mapping: Complete External Reconnaissance Guide
Learn to map external attack surfaces using OSINT tools. Master subdomain discovery, service enumeration, and asset inventory for penetration testing and bug bounty hunting.
OSINT · BeginnerHow to Use Whois: Beginner's Guide to Domain Lookups in Kali Linux
Learn how to use whois in Kali Linux: look up any domain, IP or AS number, read the record, and spot red flags — with a worked example and cheat sheet.
OSINT · IntermediateSubdomain Enumeration: Finding Hidden Attack Surface
Master subdomain enumeration techniques using passive and active methods to discover hidden subdomains and expand attack surface mapping.
OSINT · AdvancedOSINT for Bug Bounty Hunters: Reconnaissance Mastery Guide
Complete OSINT guide for bug bounty hunters. Master reconnaissance workflows, subdomain discovery, email enumeration, and attack surface mapping for successful bug bounty submissions.
Related Security Tools
DNSenum
DNSenum is a multithreaded Perl script for DNS enumeration that discovers DNS records, attempts zone transfers, brute-forces subdomains, and performs reverse lookups. It is a foundational reconnaissance tool in Kali Linux for mapping a target domain's DNS infrastructure.
Information Gatheringdig
dig (domain information groper) is a flexible tool for interrogating DNS name servers. It performs DNS lookups and displays the answers that are returned from the name server(s).
Information GatheringAmass
OWASP Amass is the industry-standard in-depth network mapping and attack surface discovery tool. It uses active and passive techniques, scraping 20+ public data feeds, DNS enumeration, and certificate transparency logs to discover subdomains, IP addresses, and ASN data — making it essential for penetration testing, bug bounty hunting, and enterprise security assessments.
Information GatheringtheHarvester
Learn how to use theHarvester in Kali Linux: gather emails, subdomains, employee names, open ports, and banners from public sources with a step-by-step first scan, API keys, and worked examples for authorized OSINT recon.