Updated: 11 October 2026 · Applies to: DNS records in cPanel Zone Editor, Cloudflare and other DNS providers; behaviour tested with BIND 9.20 and nginx 1.28 (Ubuntu 26.04)

A wildcard DNS record is a record whose name is *, for example *.example.com. It answers for every subdomain that has no record of its own. With a wildcard A record *.example.com A 203.0.113.20, the names shop.example.com, client1.example.com and even a.b.example.com all point to 203.0.113.20, without creating each name separately. It is used for multi-tenant apps (one subdomain per customer), WordPress Multisite with subdomains, preview environments and catch-all landing pages.

How a wildcard record behaves (tested)

We loaded a test zone into a BIND 9.20 DNS server with these records:

@        IN A     203.0.113.10
www      IN A     203.0.113.11
*        IN A     203.0.113.20
txtonly  IN TXT   "only a text record here"
app      IN A     203.0.113.40
*.app    IN CNAME app.example.com.

Lab results with dig:

$ dig +short random.example.com A
203.0.113.20
$ dig +short a.b.example.com A
203.0.113.20
$ dig +short www.example.com A
203.0.113.11
$ dig +short eu.app.example.com A
app.example.com.
203.0.113.40

What that means for your zone:

  • Names with their own record win. www.example.com kept its own address.
  • It covers several levels. a.b.example.com matched because b.example.com does not exist. Cloudflare documents the same: *.example.com is multi-level by default.
  • It does not cover the domain itself. In a second zone that had only *, anything.example.org resolved but example.org returned no address. Add a separate A record for the main domain (@).
  • It does not cover names that already exist, for any record type. txtonly.example.com has only a TXT record, so an A query for it returned no answer (status NOERROR) instead of the wildcard address. If you add a TXT record for a subdomain, also add the A record it needs.
  • It stops below existing names. foo.www.example.com returned NXDOMAIN: www exists, so the wildcard at *.example.com no longer applies under it. For deeper names, add a wildcard at that level, such as *.app above.
  • It only covers its own record type. An MX query for random.example.com returned no answer: a wildcard A record does not create mail, TXT or other records.
  • The * must be the whole first label. BIND’s named-checkzone flagged foo*.example.net and shop.*.example.net as bad owner names. According to Cloudflare, a * in the middle of a name is treated as a literal character.

Add a wildcard A record in cPanel

  1. Open Domains > Zone Editor and click Manage next to the domain.
  2. Click Add Record and choose type A.
  3. Name: *.example.com. Address: your server’s IP address. Click Save Record.

The DNS record only sends visitors to the server. For cPanel to serve a website on those names, create a wildcard subdomain as well: according to cPanel, open Domains > Domains, click Create A New Domain, enter *.example.com in the Domain box, choose the document root and click Submit, then check in Zone Editor that the *.example.com A record points to the right IP address. If you cannot create it on a shared plan, open a ticket with our support team. For a normal A record, see how to add an A record in cPanel; for DirectAdmin and Plesk, see DNS records in DirectAdmin and DNS records in Plesk.

Add it at Cloudflare or another DNS provider

Create an A record (or a CNAME, or AAAA for IPv6) with * in the Name field; most DNS panels add the domain for you. According to Cloudflare, customers on all plans can create and proxy wildcard records, and a record with an exact name always wins over the wildcard. For a wildcard under a subdomain, use *.app as the name. In a BIND zone file on your own VPS, the line is * IN A 203.0.113.20.

Check the wildcard

dig +short anything-you-like.example.com A
dig +short www.example.com A
dig anything.example.com A | grep status

The first command should return the wildcard address and the second the address of the named record. status: NXDOMAIN means no record and no wildcard matched. Changes can take up to the record’s TTL to show; if your computer still has the old answer, flush your DNS cache.

Make the web server answer on all subdomains

On your own VPS or dedicated server, the web server must accept the names too. The nginx server blocks below are shortened from our lab, which listened on a test port and returned a test response in each block:

server {
    listen 80;
    server_name example.com www.example.com;
    # the main site
}
server {
    listen 80;
    server_name ~^(?<sub>[^.]+)\.example\.com$;
    # one level only; $sub holds the subdomain, for example "shop"
}

A request for shop.example.com reached the second block with $sub set to shop, and a.b.example.com did not match it. The short form server_name *.example.com; matched both shop.example.com and a.b.example.com in our test. In Apache, the documentation allows wildcards in ServerAlias: add ServerAlias *.example.com to the virtual host.

Decide what unknown names should do: redirect them to the main site or return an error, so that every mistyped subdomain does not show a copy of your website. In our test, a default_server block with return 444; closed the connection for names no block accepted.

SSL for every subdomain

A wildcard DNS record does not secure anything; you also need a wildcard certificate for *.example.com. A wildcard certificate covers one level only. Lab check with a test certificate for *.example.com and example.com:

$ openssl x509 -in w.crt -noout -checkhost shop.example.com
Hostname shop.example.com does match certificate
$ openssl x509 -in w.crt -noout -checkhost a.b.example.com
Hostname a.b.example.com does NOT match certificate
  • According to Let’s Encrypt, wildcard certificates require the DNS-01 challenge (a TXT record); HTTP validation cannot issue them. Certbot does this with a DNS plugin for your DNS provider, or with --manual --preferred-challenges dns, which does not renew automatically without a hook script. acme.sh can also use a DNS provider’s API.
  • Behind Cloudflare’s proxy, Cloudflare’s Universal SSL covers the root domain and first-level subdomains, according to Cloudflare; deeper names such as dev.www.example.com are not covered.
  • Commercial wildcard certificates are available from our SSL certificates page, with free installation help.

Be careful with wildcards

  • Every mistyped or invented subdomain now reaches your server, so handle unknown names as described above.
  • Do not leave a wildcard pointing at an IP address or service you no longer use: whoever gets that address or account next could serve content under your domain.
  • Remember the rules above: an existing record of any type, or an existing name in between, stops the wildcard. Many "wildcard does not work" cases are exactly that.

More about DNS: what DNS is and how it works and what a nameserver is.

Official documentation: Cloudflare wildcard DNS records, Let’s Encrypt challenge types and RFC 4592 (wildcards in DNS).

Was this answer helpful?

Still stuck? Open a ticket