> ## Documentation Index
> Fetch the complete documentation index at: https://www.0101isnothacking.nl/llms.txt
> Use this file to discover all available pages before exploring further.

# DNS enumeration

> DNS enumeration commands and zone transfer techniques for port 53.

DNS (Domain Name System) works on port 53.

## General information

Hosts file paths:

```text theme={null}
C:\Windows\System32\drivers\etc\hosts
/etc/hosts
```

![General information](https://mintcdn.com/non-9fcb5a21/P-t86H21MW2fT7Il/images/b2029b423c62.png?fit=max\&auto=format\&n=P-t86H21MW2fT7Il\&q=85\&s=ce0ba241c58c5a7d523496d491136d6d)

## Check open ports

```bash theme={null}
nmap -p53 <ip>
```

## Nmap scripts

```bash theme={null}
# Service and version detection
nmap -p53 -sVC -A <ip>

# DNS zone transfer script
nmap -p53 --script dns-zone-transfer <ip>
```

> [!NOTE]
>
> You have to find the domain in order to be able to perform enumeration on the DNS, so try to gather information using ldap, dns ns, nmap scripts.

## Check NS server

```bash theme={null}
host -t ns <ip-or-domain>
```

## Zone transfer

```bash theme={null}
dig axfr <domain> @<ip>
```

## Add the domain or NS

Add the domains and subdomains to the `/etc/hosts` file.

![Add domains to /etc/hosts](https://mintcdn.com/non-9fcb5a21/P-t86H21MW2fT7Il/images/d8eef552c450.png?fit=max\&auto=format\&n=P-t86H21MW2fT7Il\&q=85\&s=b18f581e187b6dee24402662fe0f7e11)

Add the NS to the `/etc/resolv.conf` file.

![Add NS to /etc/resolv.conf](https://mintcdn.com/non-9fcb5a21/P-t86H21MW2fT7Il/images/2c80f4c18bb5.png?fit=max\&auto=format\&n=P-t86H21MW2fT7Il\&q=85\&s=b197bc265b68f9d2e670c669db548211)

## Steps

![Steps](https://mintcdn.com/non-9fcb5a21/P-t86H21MW2fT7Il/images/9ba97bbab9e5.png?fit=max\&auto=format\&n=P-t86H21MW2fT7Il\&q=85\&s=38b33e80577ae6c9a23a23ddcdcfca15)

## Dangerous settings

| Setting | Description |
| - | - |
| `allow-query` | Defines which hosts are allowed to send requests to the DNS server. |
| `allow-recursion` | Defines which hosts are allowed to send recursive requests to the DNS server. |
| `allow-transfer` | Defines which hosts are allowed to receive zone transfers from the DNS server. |
| `zone-statistics` | Collects statistical data of zones. |

## Useful commands and tools

```bash theme={null}
# IPv4 records
dig a <domain>

# IPv6 records
dig aaaa <domain>

# Name servers
dig ns <domain>

# Mail servers
dig mx <domain>

# Start of authority
dig soa <domain>

# Any available information
dig any <domain> @<ip>

# Zone transfer (subdomains)
dig axfr <domain> @<ip>

# Server version
dig version.bind <domain> @<ip>

# Brute force subdomains
dnsenum --enum inlanefreight.com -f /usr/share/seclists/Discovery/DNS/subdomains-top1million-110000.txt -r
```

> [!NOTE]
>
> dnsenum can be given short or quiet output flags for a shorter answer.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.