A wildcard record steers requests for multiple subdomains to the same resources, even if the requested subdomain does not exist. Wildcard records are used as the response if no unique record corresponds to that specific domain. This type of configuration can help simplify DNS resource management and makes it easier to scale your configuration as subdomains are created and modified.
Wildcard records are indicated by an asterisk that appears in the leftmost segment of the domain name, such as *.example.com or *.sub.example.com. The asterisk must be placed at the beginning of the domain name, and there can only be one wildcard segment in the domain name. They are typically applied to record types A, AAAA, ALIAS, CNAME, TXT, URLFWD, and MX.
If you configure a DNS zone for the fully qualified domain name (FQDN), example.com, you can create an A record that uses a wildcard domain, *.example.com, the content in that A record will be returned to anyone who requests a subdomain of example.com. In other words, if someone requests access to sub.example.com, bar.sub.example.com, or foo.bar.example.com, all three queries will be resolved by the A record for *.example.com.
If a record for a specific subdomain is configured that would otherwise match the wildcard record domain, then the non-wildcard record will take priority. For example, if you have two records: www.example.com and *.example.com, and a client requests www.example.com, the query will resolve to the record for www.example.com.
For example, if you have an A record for *.example.com and a second A record for sub.example.com, then a DNS lookup for sub.example.com resolves to the record for sub.example.com. specific to the domain. In this case, a lookup for bar.sub.example.com will return an NXDOMAIN response since the initial match is made for sub.example.com. One option to address this is by creating another wildcard record with the domain name *.sub.example.com.
If you have multiple subdomains you want to point to the same resources, consider using a wildcard record instead of creating individual records for each subdomain and updating each of them every time there is a change.