Today, I have the pleasure to announce that we’re giving everyone the ability to proxy DNS wildcard records. Previously, this feature was only available to our Enterprise customers. After many of our free and pay-as-you-go users reached out, we decided that this feature should be available to everyone.
What is a wildcard DNS record?
A DNS record usually maps a domain name to one or multiple IP addresses or another resource associated with that name, so it’s a one-to-many mapping. Let’s look at an example:
When I do a DNS lookup for the IP address of
subdomain1.mycoolwebpage.xyz, I get two IP addresses back, because I have added two A records on that subdomain:
$ dig subdomain1.mycoolwebpage.xyz -t a +short 192.0.2.1 192.0.2.2
I could specify the target of all subdomains like this, with one or multiple DNS records per subdomain. But what if I have hundreds or even thousands of subdomains that I all want to point to the same resource?
This is where a wildcard DNS record comes in. By using the asterisk symbol
"*" in the Name field, I can create one or multiple DNS records that are used as the response for all subdomains that are not specifically covered by another DNS record (more on this later). So the wildcard record you can see in the screenshot above is covering
*.mycoolwebpage.xyz, meaning all subdomains of
mycoolwebpage.xyz. This can also be done on deeper levels, like on
If I perform a lookup for
subdomain2.mycoolwebpage.xyz, the target I specified in the wildcard record will be used as the response. Again, this is only happening because there is no DNS record specifically for this subdomain.
$ dig subdomain2.mycoolwebpage.xyz -t a +short 192.0.2.3
And it is often overlooked that a wildcard record does not only cover the level it is set on directly, but deeper levels, as well:
$ dig some.deep.label.subdomain2.mycoolwebpage.xyz -t a +short 192.0.2.3
Also, a wildcard DNS record does not cover the apex of the zone (in this example the apex is
A few more things to know about wildcard records
Below you can find additional rules that apply to wildcard DNS records you should be aware of:
Wildcards are only supported on the first label. Meaning something like
subdomain.*.mycoolwebpage.xyz is not a wildcard on the level of the asterisk character. If you create a DNS record with that name, the asterisk is interpreted as the literal character and not as the wildcard operator.
You cannot create wildcards on multiple levels. So if you create a DNS record on
*.*.mycoolwebpage.xyz, only the first asterisk is interpreted as a wildcard while the second one is interpreted as the literal
Wildcards will be applied for multiple levels. But a specific record on any equal or lower level will terminate anything on or below this specific record — independent of the type of that specific record. Here is an example. If you have only these two records on your domain
subdomain1.mycoolwebpage.xyz TXT “some text” *.mycoolwebpage.xyz A 192.0.2.3
the wildcard record will be used for queries going to any subdomain of
subdomain1.mycoolwebpage.xyz or anything below that specific label, like
deeper.label.subdomain1.mycoolwebpage.xyz — simply because there already exists a record on
subdomain1.mycoolwebpage.xyz. However, the wildcard will be used for deeper labels that are not below the specific record on subdomain1 — for example,
To expand on this rule: if you think of DNS as a tree starting from the root zone (see the diagram below), simply the existence of a branch terminates the wildcard for all records on that branch. In the example above the wildcard was terminated for anything on the label subdomain1 and below, but even if there only exists a record on a deeper level, anything above will also be terminating the wildcard. This example should make it clear. If you only have the following two records on your domain, as shown in the diagram below
some.deep.label.subdomain1.mycoolwebpage.xyz TXT “some other text” *.mycoolwebpage.xyz A 192.0.2.3
a query to
label.subdomain1.mycoolwebpage.xyz for an A record is not covered by the wildcard because it is a node on the existing branch ending in the TXT record above.
Wildcard records only cover the record type they are specified for. If you add a wildcard A record for
*.mycoolwebpage.xyz it will not cover queries specifying AAAA records (or any other type). But as mentioned in the previous point, a record on a specific label will terminate the wildcard for this label and everything below even if it’s a different record type.
All the above and more can be found in RFC4592. Not the type to read through complex RFCs but still generally interested in how DNS works, go check out Julia Evans’ wizard zines about DNS, she did a great job explaining all the complexities about DNS in an easy to digest way.
What is a proxied wildcard DNS record?
Cloudflare provides a range of features (including Caching, Firewall, or Workers) that require you to proxy the specific hostname you want to use these features on. You can proxy DNS records of the type A, AAAA, and CNAME. These record types are used to specify the origin server of a hostname which expects traffic via HTTP/S.
Proxying a wildcard DNS record works exactly as proxying a specific record. In the Cloudflare dashboard, navigate to the DNS app and either create a new wildcard record or edit an existing record and toggle the proxy status to Proxied. Previously, we only allowed this on wildcard records if the domain was upgraded to the Enterprise plan, but this feature is now available on all plan levels!
Once you have enabled the proxy status of your wildcard DNS record, Cloudflare nameservers will respond with two Cloudflare anycast IPs instead of the origin IP(s) you have specified for that record. These Cloudflare IPs are advertised on our global network from more than 275 locations in more than 100 countries.
$ dig subdomain2.mycoolwebpage.xyz -t a +short 188.8.131.52 184.108.40.206
In the example above, this will ensure that all HTTP/S requests sent to
subdomain2.mycoolwebpage.xyz or any other subdomain that is covered by the proxied wildcard DNS record are proxied by Cloudflare’s network, specifically the closest Cloudflare data center. Go see for yourself and pick a random subdomain of
mycoolwebpage.xyz. You will see a simple page that is generated using Cloudflare Workers:
And the cool thing is that you don’t even have to think about creating a TLS certificate. By default, Cloudflare will issue and automatically renew a certificate for your zone apex (
mycoolwebpage.xyz) and all subdomains on the next level (
If you want to proxy a wildcard DNS record on a deeper level like
*.www.mycoolwebpage.xyz you can subscribe to Cloudflare Advanced Certificate Manager and get a certificate that is covering that wildcard like this:
Try it yourself on your domain
If you are not already using Cloudflare DNS for your domain, it is very easy to move from your existing DNS provider and can be done in a few minutes. Head over to our developer documentation for detailed instructions on how to change your authoritative nameservers.