> For the complete documentation index, see [llms.txt](https://the-pentesting-guide.marmeus.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://the-pentesting-guide.marmeus.com/active/services/53-dns.md).

# 53 - DNS

## Introduction

**Port**: 53 (TCP/UDP) There are two main reasons why **Domain Name System** (DNS) enumeration is essential. First, enumerating the number of domains and sub-domains can reveal how large or small the organisation is. Secondly, virtual routing may be enabled in the company's web server, responding to different web pages depending on the accessed domain.

## Enumeration

There will typically be a dedicated DNS server inside an enterprise environment. In order to identify it, search for TCP or UDP port 53 on the network hosts.

```bash
nmap -n -sT -p53 <NETWORK>/<MASK>
nmap -n -sU -p53 <NETWORK>/<MASK>
```

Then, you can use the following commands to retrieve domains and subdomains based on IPs.

```bash
dig -x <IP> @<DNS_SERVER_IP>       # Reverse lookup
dig ANY @<DNS_SERVER_IP> <DOMAIN>  # Any information
dig axfr @<DNS_SERVER_IP> <DOMAIN> # zone transfer 
# Subdomain brute forcing
gobuster dns -d <DOMAIN> [ -r <DNS_SERVER_IP>] -w <WORDLIST.TXT>  [ -t <NUMBER_THREADS>] 
dnsrecon -t brt -d <DOMAIN> [-n <DNS_SERVER_IP>] -D <WORDLIST.txt> [ --threads <NUMBER_THREADS>]
```

If you want to obtain domains but you do not have an internal DNS server, you can use the tools on the OSINT section or the following commands.

```bash
dnsrecon -n 8.8.8.8 -d <DOMAIN>
dnsrecon -d <IP> -t zonewalk
dnsrecon -d <DOMAIN> -t axfr # Zone transfer
dnsrecon -r <IP>             # Reverse lookup
```

## References

* [Back to Basics: DNS Enumeration](https://medium.com/@klockw3rk/back-to-basics-dns-enumeration-446017957aa3)
* [Pentesting DNS](https://book.hacktricks.xyz/pentesting/pentesting-dns)
* [DNS Reconnaissance – DNSRecon](https://pentestlab.blog/2012/11/13/dns-reconnaissance-dnsrecon/)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://the-pentesting-guide.marmeus.com/active/services/53-dns.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
