Blog / How the internet works /

Wildcard DNS explained

Type a random word in front of some domains, anything.example.com, and the site still loads. That is not magic or luck. Somebody set up a wildcard DNS record, a single entry that answers for every subdomain nobody bothered to define.

A wildcard DNS record uses an asterisk as the name (*.example.com) and matches any subdomain that does not have its own record. It’s a catch-all for names.

The analogy: a catch-all mailbox

Imagine a building where every flat has its own mailbox. The caretaker also puts up one big box marked “everything else”. Letters addressed to flats that don’t exist land there instead of being returned.

A wildcard record is the “everything else” box. Specific records still win, so blog.example.com goes where its own record sends it. Only names with no record fall through to the wildcard.

What it looks like

Type Name Value
A @ 203.0.113.10
A www 203.0.113.10
A blog 203.0.113.20
A * 203.0.113.10

With these records:

  • example.com and www.example.com go to the first server.
  • blog.example.com goes to the second, because the specific record beats the wildcard.
  • shop.example.com, xyz.example.com and any other undefined subdomain go to the first server, through the wildcard.

You can create wildcards for A, AAAA, CNAME, MX and TXT records. The basics of these are in DNS records explained: A, AAAA, CNAME, MX and TXT.

The rules that catch people out

  1. Specific beats wildcard. If a name has any record of that type, the wildcard doesn’t apply to it. Most DNS providers follow the standard on this.
  2. The wildcard covers one level only. *.example.com matches foo.example.com. Whether it matches a.b.example.com depends on whether b.example.com exists; the standard rules are subtle, so test rather than assume.
  3. It doesn’t cover the bare domain. example.com itself needs its own record.
  4. Records of other types can interact. If blog has only a TXT record, the DNS standards may treat the name as existing and a wildcard A record may not apply to it. This can produce surprising results, so after adding a wildcard, check each important subdomain.
  5. A wildcard MX is rarely a good idea. It can send mail for any made-up subdomain to your mail server.

Where wildcards are useful

  • Multi-tenant apps. A service that gives every customer their own address (customer.app.com) can point all of them to one system without adding a record each time.
  • Staging and preview sites. Developers use patterns such as pr-123.preview.example.com, with one wildcard record covering all of them.
  • User-generated sites. Blog platforms and site builders hand out username.platform.com.
  • Catch-all for typos. Sending unknown subdomains to a helpful page or to the main site.
  • Wildcard SSL certificates. Covered below.

Where they cause trouble

Security: subdomain takeover and phishing

If a wildcard points to a server that responds to every name, attackers can use any subdomain on your domain to host content, and it looks trustworthy, because it’s your domain. Also a dangling wildcard pointing at a service you stopped using can be claimed by someone else. If you don’t need a wildcard, don’t create one.

SEO: infinite duplicate pages

If every possible subdomain returns your homepage, search engines could discover endless copies of your site, such as random.example.com, and treat them as duplicates. Fixes include:

  • Having the server return a 404 for names you don’t recognise, rather than your main site.
  • Redirecting unknown subdomains to the main domain with a 301. See redirects explained: 301 vs 302.
  • Using canonical tags that point to the right domain.
  • Making sure you never link to junk subdomains yourself.

Subdomains also raise the question of structure; subdomain or subfolder for your blog goes through when each is the better choice.

Hiding mistakes

A wildcard makes typos in your own settings harder to notice. wwww.example.com works, so you never discover that a link is wrong.

Email confusion

If a wildcard A record exists but you also use email, remember that email depends on MX records. They are separate, as described in MX records explained.

Wildcard DNS vs wildcard SSL

These are different things, often confused.

  • Wildcard DNS decides where a name goes.
  • A wildcard SSL certificate (*.example.com) secures any single-level subdomain with one certificate.

You can have one without the other. A wildcard DNS record doesn’t give you HTTPS, and a wildcard certificate doesn’t create DNS entries. Free wildcard certificates are available from Let’s Encrypt, which validates them using DNS records, and many CDNs and hosts also offer them. The background is in how HTTPS works, simply.

When to use one

Use a wildcard if:

  • You deliberately offer unlimited subdomains, such as a platform or a preview system.
  • You can control what happens for unknown names on the receiving server.
  • You’ve thought about the security and SEO effects.

Skip it if:

  • You have a handful of known subdomains. Add them explicitly.
  • You don’t have a clear reason. Convenience isn’t one.

How to test your setup

  1. Visit a made-up subdomain such as thisdoesnotexist.yourdomain.com.
  2. If it loads your site, ask whether it should. If not, tighten the server rules.
  3. Check headers and redirects with a header checker.
  4. Use dig or an online DNS tool to see what the wildcard returns.
  5. Search site:yourdomain.com to see if odd subdomains are indexed.
  6. Review your records twice a year and remove anything you don’t recognise.

Key takeaways

  • A wildcard record answers for subdomains without their own record.
  • Specific records always take priority, and the bare domain isn’t covered.
  • Wildcards are excellent for platforms and previews, risky when used out of convenience.
  • Control what the server does for unknown names, to avoid duplicate pages and abuse.
  • Wildcard DNS and wildcard SSL are different things.

FAQ

Does a wildcard record slow DNS?

No noticeable difference. It’s one more answer in the zone.

Can I use a wildcard with Cloudflare?

Yes, though proxy and plan options vary, so check the current documentation for what applies to wildcard records.

Is a wildcard record the same as a catch-all email address?

No. Email catch-all is a mailbox setting at the mail provider, and MX records decide where mail goes.

Test a made-up subdomain on your own domain today. What it returns will tell you whether you have a wildcard you forgot about.