Black Friday: 60% off yearly plans with code BF2026, until November 30. See the deal

Learn

Wildcard DNS record: how *.example.com matches subdomains

A wildcard DNS record has a name starting with an asterisk, such as *.example.com, and answers queries for any subdomain that has no record of its own. It matches only the missing names, never example.com itself and never a name that already exists.

The short answer
  • Only a leftmost * label is a wildcard. A name that exists explicitly is never replaced by it.
  • The wildcard does not cover the bare domain, and *.example.com does not match a.b.example.com.
  • DNS wildcards and wildcard TLS certificates are separate things.
Try the dns lookupFree, live, no signup

Which names does *.example.com match?

Zone has: *.example.com A 192.0.2.10 and www.example.com A 192.0.2.20
QueryAnswerWhy
blog.example.com192.0.2.10No explicit record, so the wildcard answers
www.example.com192.0.2.20An explicit record exists, so the wildcard is not used
example.comNo answerThe wildcard does not match its own parent
a.b.example.comNo answerDeeper names need *.b.example.com (or a record under b)
blog.example.com (type MX)No answerOnly record types present at the wildcard are synthesized

Rules from RFC 4592 and RFC 1034, 4.3.3. A name with other records below it can also block matching.

How do you write one?

Zone file syntax
*.example.com.     3600 IN A      192.0.2.10
*.example.com.     3600 IN AAAA   2001:db8::10
; wildcard CNAME for a multi-tenant app
*.app.example.com. 3600 IN CNAME  tenants.example-saas.net.

When is a wildcard record worth using?

Multi-tenant apps

Each customer gets customer.example.com without a DNS change per customer.

Catch-all for dev and preview hosts

Preview environments resolve automatically; the server decides which to serve.

Beware typos and abuse

Every misspelled subdomain resolves, which hides mistakes and can aid phishing. Keep the server strict.

How do you add and test a wildcard record?

  1. 01

    Add the record

    Type A, AAAA or CNAME, name *, value as for a normal record. Some panels write the name as * and some as *.example.com.

  2. 02

    Keep explicit records

    Existing www, mail and api records keep working; the wildcard fills only the gaps.

  3. 03

    Test a made-up name

    Run nslookup definitely-not-real.example.com 1.1.1.1. It should return the wildcard value.

  4. 04

    Configure the server

    The web server must accept unknown hostnames (a default virtual host) and TLS needs a wildcard certificate or one per name.

What should you confirm before relying on a wildcard?

  • The apex has its own record, since the wildcard does not cover it
  • Every subdomain that needs a different target has its own explicit record
  • The application rejects hostnames it does not recognize instead of serving a default site
  • Your TLS certificate covers the names visitors actually use
  • Mail records (MX) exist on names that receive email, because wildcard matching has exceptions

How does a wildcard interact with other records?

Explicit wins

A name with any record of its own is not answered by the wildcard for other types if that name exists.

Type by type

A wildcard A record does not create MX answers. Each type you need must be added at the wildcard.

Nested wildcards

RFC 4592 allows more than one asterisk label, such as *.*.example.com, but support differs by DNS host.

Common questions

What is a wildcard DNS record?

A wildcard record uses an asterisk as the leftmost label, such as *.example.com. The name server answers with its value for any query under that name that has no more specific record.

Does *.example.com include example.com?

No. A wildcard never matches the name it hangs from. The root domain needs its own record, so a zone usually has both an apex A record and a wildcard.

Do wildcard DNS records work with MX records?

A wildcard can carry MX, but only for names that have no records of their own, and an explicit record on a name stops the wildcard from applying there. Test with a made-up subdomain before relying on it.

Is a wildcard DNS record the same as a wildcard SSL certificate?

No. The DNS wildcard decides which address a subdomain resolves to. A wildcard certificate decides which hostnames a TLS certificate covers. You usually need both for unlimited subdomains over HTTPS.

Why does my wildcard record not match the root domain?

A wildcard only matches names below it, so *.example.com never answers for example.com itself. Add a separate record for the root domain, usually an A record, and keep the wildcard for subdomains.

Watch your domains automatically

Aepto monitors expiry, DNS, SSL and uptime for every domain you own and alerts you when something changes. Free for 3 domains.