Domains

How to Create a Wildcard Subdomain (*) in Your DNS Step by Step

Learn what a wildcard subdomain is, when to use one, and how to add the asterisk DNS record in cPanel, Cloudflare, and BIND.

From below of fiber optic switch with sockets and connected rubber cables on blurred background

A wildcard subdomain is a DNS record using the asterisk character (*) that causes any subdomain not explicitly defined in your zone to point to the same destination. It is the fastest way to support client1.yourdomain.com, client2.yourdomain.com, and thousands more without creating an individual record for each one.

What Is a Wildcard Subdomain and When Should You Use It?

A wildcard record looks like this in your DNS zone:

*.yourdomain.com.  IN  A  203.0.113.10

The asterisk acts as a catch-all: any label that appears before the dot is covered. If a subdomain already has its own record (for example, www), that explicit record takes priority over the wildcard.

The most common use cases are:

  • SaaS multitenancy: each customer reaches their own subdomain (company.app.com).
  • Dynamic staging environments: branch deployments at feat-login.staging.com, fix-bug.staging.com, etc.
  • Reseller portals: each reseller gets their subdomain automatically.
  • Typo recovery: redirect ww.yourdomain.com or catch any variation without defining every case.

Before You Create the Wildcard: What You Need to Know

A wildcard DNS record does not configure the web server on its own. It only tells DNS where to send traffic. For the subdomain to actually serve content, the server (Apache, Nginx, etc.) must also be configured to accept any ServerName or use a wildcard virtual host.

Additionally, a standard TLS certificate does not cover wildcard subdomains. You will need a wildcard certificate (*.yourdomain.com), either from your CA or via Let's Encrypt using the DNS-01 challenge.

Component Does the wildcard DNS handle it?
Name → IP resolution Yes
Web server configuration No (configure Apache/Nginx separately)
TLS certificate No (you need a wildcard cert)

Step by Step: Creating the Wildcard DNS Record

Option A — cPanel (Zone Editor)

  1. Log in to cPanel and go to Domains → Zone Editor.
  2. Click Manage next to the domain you want to configure.
  3. Click Add Record.
  4. In the Name field, type * (just the asterisk).
  5. In Type, select A (for an IPv4 address) or CNAME if pointing to another hostname.
  6. In Record, enter the IP address or the target hostname.
  7. Click Save Record.

The resulting plain-text record would be: *.yourdomain.com. 14400 IN A 203.0.113.10

Option B — Cloudflare

  1. In the Cloudflare dashboard, select your domain and go to DNS → Records.
  2. Click Add record.
  3. Type: A (or CNAME).
  4. Name: *
  5. Content: the IP address or target hostname.
  6. Proxy: you can enable the orange cloud ☁ if you want Cloudflare to handle wildcard traffic (includes DDoS protection and caching).
  7. Click Save.

With the proxy enabled, Cloudflare resolves all undefined subdomains to your IP without exposing it directly.

Option C — BIND Zone File

If you manage your own DNS server with BIND, edit the zone file for your domain (usually in /etc/named/ or /var/named/) and add:

*    IN    A    203.0.113.10

Or with a fully qualified name:

*.yourdomain.com.    IN    A    203.0.113.10

Then reload the zone without restarting the service:

rndc reload yourdomain.com

How to Verify the Wildcard Is Working

Wait for TTL propagation (5–30 minutes for Cloudflare changes; up to 24 h for zones with a high TTL) and then test:

  • dig anything.yourdomain.com +short — should return the IP you configured.
  • nslookup randomtest.yourdomain.com — alternative on Windows/macOS.
  • From the browser: navigate to http://xyz123.yourdomain.com and confirm it reaches your server.

If the subdomain does not resolve, verify that the record was saved correctly and that no conflicting record exists.

Common Mistakes and Security Considerations

  • The wildcard does not cover the root domain: *.yourdomain.com does not apply to yourdomain.com itself. Add a separate A record for the apex.
  • Phishing and abuse: an open wildcard can be exploited to create deceptive subdomains if the web server accepts them without filtering. Implement application-level validation for the subdomains you permit.
  • TLS certificates: Let's Encrypt issues wildcard certs, but only via the DNS-01 challenge — you must be able to write DNS TXT records programmatically. The HTTP-01 challenge does not support wildcards.
  • SPF and email: the wildcard can interfere with mail records if your mail subdomains (mail., smtp.) are not defined explicitly. Explicit records always win, so define them.

If your project involves multitenancy or dynamic subdomain generation, our team at elenlace.com can advise you on the right DNS and web server architecture from the start.

You can also explore our full collection of guides in the domains article library for deeper DNS management topics.

Key Takeaways

  • A wildcard DNS record (*) routes any undefined subdomain to the destination you specify.
  • You must also configure the web server and, for HTTPS, a wildcard TLS certificate.
  • cPanel, Cloudflare, and BIND all support wildcards with slight interface differences.
  • Always verify with dig or nslookup after making the change.
  • Control which subdomains your application accepts to prevent abuse.

Ready to enable a wildcard on your domain? Contact us at elenlace.com — we will help you set up DNS, web server, and TLS securely from day one.

FAQ

Does a wildcard DNS record affect subdomains I have already configured?

No. Explicit records always take priority over the wildcard. If you already have www, mail, or shop defined, the wildcard leaves them untouched.

Can I use a wildcard CNAME instead of a wildcard A record?

Yes. Instead of pointing directly to an IP, you can point the wildcard to another hostname (*.yourdomain.com CNAME destination.example.com). This is useful when the destination has a dynamic IP or already uses its own canonical name.

Does a wildcard DNS record work with Let's Encrypt?

Yes, but Let's Encrypt only issues wildcard certificates using the DNS-01 challenge, which requires writing a temporary TXT record programmatically. Tools like Certbot with your DNS provider's plugin automate this process.

How long does it take for the wildcard record to propagate?

It depends on your zone's configured TTL. Cloudflare typically propagates changes in 1–5 minutes. On self-hosted zones with a 14400-second (4-hour) TTL, changes can take up to that long to be seen globally.

Compare providers

Other providers and guides worth comparing:

← All