What is Wildcard DNS?
Wildcard DNS is a DNS configuration that uses an asterisk (*) to match requests for any subdomain that doesn't have an explicit DNS record defined. A wildcard record like *.example.com catches all queries for undefined subdomains (blog.example.com, app.example.com, anything.example.com) and resolves them to the specified destination.How Wildcard DNS Works
DNS Zone for example.com:
├── example.com A 192.0.2.1 (explicit)
├── www.example.com A 192.0.2.1 (explicit)
├── mail.example.com A 192.0.2.2 (explicit)
└── *.example.com A 192.0.2.10 (wildcard)
Query: random.example.com → 192.0.2.10 (matched by wildcard)
Query: www.example.com → 192.0.2.1 (explicit takes priority)
Wildcard Record Syntax
*.example.com. 3600 IN A 192.0.2.10
*.example.com. 3600 IN CNAME catch-all.example.com.
*.example.com. 3600 IN MX 10 mail.example.com.
Common Use Cases
Multi-Tenant SaaS Applications
*.myapp.com → Single server handles:
├── customer1.myapp.com
├── customer2.myapp.com
├── customername.myapp.com
└── (unlimited subdomains)
Development Environments
- Any subdomain works without setup
- Quick testing of features
- Dynamic preview environments
User-Generated Content
- username.platform.com
- projectname.service.com
- Custom branded subdomains
Wildcard Priority Rules
| Record | Query for test.example.com |
|---|---|
| test.example.com (explicit) | ✓ Matches first |
| *.example.com (wildcard) | Matches if no explicit |
Explicit records always take priority over wildcards.
Limitations
1. Only matches one level: *.example.com doesn't match a.b.example.com
2. Can't be at apex: *.com is not allowed
3. Security considerations: May catch unintended subdomains
4. SSL complexity: Requires wildcard SSL certificate
DNS Configuration Example
; Zone file
$ORIGIN example.com.
@ A 192.0.2.1 ; apex
www A 192.0.2.1 ; explicit www
* A 192.0.2.10 ; everything else
* MX 10 mail.example.com. ; wildcard mail
Best Practices
1. Use sparingly: Only when truly needed
2. Combine with SSL: Get wildcard certificate
3. Application handling: Server must route subdomains correctly
4. Monitor usage: Watch for unexpected subdomain access
5. Explicit overrides: Create specific records for known subdomains
Wildcard DNS enables flexible subdomain handling without requiring individual DNS records for each subdomain, ideal for dynamic applications and multi-tenant platforms.