Ask a small IT team how many subdomains their company has and the honest answer is often "about a dozen, probably". Then someone runs a proper search and finds forty, including a staging site from 2019, a forgotten marketing landing page and a DNS record pointing at a cloud service nobody pays for any more. If you want to find subdomains of your domain before someone else does, this guide shows the sources that matter, a few commands to pull them together, and what to do with the list. Everything here is for domains you own or manage with permission.

Why subdomain discovery matters

Every subdomain is a door. Most are fine. The risky ones are the ones nobody remembers:

  • Old test or staging sites running outdated software.
  • Admin panels or dashboards that were meant to be temporary.
  • Dangling DNS records: a CNAME that still points to a deleted cloud resource. If someone else can claim that resource, they may be able to serve content on your subdomain. Removing the record is the defensive fix.
  • Hosts with expired or soon-to-expire certificates that break trust for users.

You cannot patch, monitor or retire what is not on your list, which is why asset inventory comes first in most security frameworks.

Source 1: your own DNS

The most reliable list is the one you already have. Export it from wherever your DNS is hosted:

  • Cloudflare: the DNS records page has an export option that produces a BIND-style zone file.
  • AWS Route 53: list the records of each hosted zone with the CLI.
  • Other registrars and hosts: most offer a zone file export or at least a records table.
aws route53 list-resource-record-sets \ --hosted-zone-id Z0123456789EXAMPLE \ --query "ResourceRecordSets[].[Name,Type]" --output text 

Two catches. First, many companies have more than one DNS provider: a legacy registrar, a separate account for marketing, a subsidiary. Find all of them. Second, your zone shows what is configured, not what the world has seen. That is where certificate logs help.

Source 2: certificate transparency subdomains

Major browsers only trust public TLS certificates that are recorded in public Certificate Transparency logs, so practically every hostname you ever put on a public certificate is on record. The mechanism is defined in RFC 6962 (and version 2.0 in RFC 9162). For defenders this is useful: certificate transparency subdomains include names created by other teams, agencies and SaaS providers on your behalf.

crt.sh is a free search interface over these logs. The % wildcard (URL-encoded as %25) matches any subdomain, and output=json returns machine-readable results:

curl -s "https://crt.sh/?q=%25.example.com&output=json" \ | jq -r '.[].name_value' \ | sed 's/^\*\.//' \ | sort -u > ct-names.txt 

name_value can hold several names separated by newlines, which jq -r prints one per line. The sed step strips the *. from wildcard entries. crt.sh can be slow or time out for large domains; run it again later, or query smaller parts such as %25.shop.example.com.

Keep in mind:

  • Wildcard certificates (*.example.com) hide the actual hostnames behind them.
  • Hosts that only use internal or private certificates never appear.
  • Old names stay in the logs forever, so a name in CT is a lead, not proof that the host still exists.

The flip side: internal hostnames on public certificates are visible to everyone. If you see names like vpn-admin or payroll-test, consider whether they need public certificates at all.

Source 3: passive discovery tools

Open-source tools combine many passive sources (certificate logs, public DNS datasets, search engines and archives) into one list. Two widely used ones:

  • subfinder by ProjectDiscovery, built for passive subdomain discovery.
  • OWASP Amass, which maps external assets and their relationships.
subfinder -d example.com -silent > passive-names.txt 

Passive tools only read data already published elsewhere, so they do not send traffic to your hosts. Active techniques, such as guessing names against your DNS servers, should only be used on domains you control, and with your DNS provider's rate limits in mind.

Source 4: everything else you already know

Some subdomains are only visible in your own records:

  • Web server and load balancer configs (server_name in nginx, virtual hosts in Apache).
  • Cloud console listings: CDN distributions, app hosting, storage endpoints.
  • Email and marketing tools that asked you to add DNS records.
  • Invoices from hosting providers and agencies.

Merge, resolve and check what is live

Combine the lists and see which names still resolve:

cat zone-names.txt ct-names.txt passive-names.txt | sort -u > all-names.txt while read -r host; do ips=$(dig +short "$host" A | tr '\n' ' ') cname=$(dig +short "$host" CNAME) echo "$host | A: ${ips:-none} | CNAME: ${cname:-none}" done < all-names.txt > resolved.txt 

Now sort every name into one of four buckets:

Status What it means Action
Live and known Resolves, has an owner Add to inventory, monitor
Live and unknown Resolves, nobody claims it Find the owner before anything else
CNAME to nothing Points at a deleted service Remove the DNS record
Not resolving Only historical Note it, no action needed

For live hosts, check the basics from outside: does it serve HTTPS, when does the certificate expire, and is the software current? A quick certificate check:

echo | openssl s_client -connect shop.example.com:443 \ -servername shop.example.com 2>/dev/null \ | openssl x509 -noout -subject -enddate 

Make subdomain discovery a routine

A one-off list goes stale within weeks. A sustainable routine:

  1. Monthly: re-run CT and passive discovery, diff against last month, and investigate new names.
  2. On every DNS change: require an owner and a purpose for each new record.
  3. On every decommission: delete DNS records in the same change as the resource they point to.
  4. Quarterly: review the inventory with each owner and retire what is no longer needed.
  5. Always: scan or test only the hosts that are confirmed as yours and in an agreed scope.

Mapping your external exposure continuously

Doing this by hand works for one domain. For several domains, or for an MSP looking after many clients, it is easier to let a tool watch for changes. CerberusGuard runs DNS and certificate transparency discovery for the domains in your authorised scope, alerts you when a new host appears, and flags expiring or untrusted TLS certificates. Discovered hosts can then be scanned with Nuclei, OWASP ZAP or Nmap service detection, but only within a signed scan authorisation, and on SaaS only after you prove domain ownership with a DNS TXT record or a file. Map your external exposure with CerberusGuard.

Originally published at CerberusGuard blog.