All Products
Search
Document Center

Alibaba Cloud DNS:Wildcard DNS

Last Updated:Sep 10, 2025

Wildcard DNS uses an asterisk (*) as the host record to point all subdomains to the same IP address (record value). For example, if you configure wildcard DNS for *.example.com, all subdomains of example.com, such as a.example.com and b.example.com, will point to the same IP address as *.example.com.

Scenarios

You can configure wildcard DNS to redirect all subdomains of a domain name, specify a single entry point for them, or resolve them to a fallback service page.

Supported record types for wildcard domain names

A, AAAA, CNAME, NS, MX, TXT, CAA, Explicit/Implicit URL, SVCB, and HTTPS records.

Method

  1. On the Alibaba Cloud DNS - Authoritative DNS page, click the target domain name to open the DNS Settings page.

  2. On the DNS Settings page, click the Add Record button.

    image

  3. Verify the configuration.

    Run the dig a.example.net command to verify that the returned DNS record matches the value that you configured.

Wildcard DNS query rules

  • A DNS query first attempts to match a line, and then attempts to match a domain name.

  • For the same line, an exact-match domain name has a higher priority than a wildcard domain name. The wildcard record is used only if no other records match the query.

  • If a query matches a wildcard record on a smart line and an exact-match record on the default line, the exact-match record from the default line is used.

Example 1

Host Record

Record Type

Line

Record Value

www.example.com

A

Default

1.1.1.1

api.example.com

A

Default

2.2.2.2

*.example.com

A

Default

3.3.3.3

  • Query for www.example.com → Returns 1.1.1.1 (matches the exact A record, not the wildcard record).

  • Query for api.example.com → Returns 2.2.2.2 (matches the exact A record, not the wildcard record).

  • Query for test.example.com → No exact match is found. The wildcard record is used and 3.3.3.3 is returned.

  • Query for abc.def.example.com (a second-level subdomain) → No exact match is found. The wildcard record is used and 3.3.3.3 is returned.

Example 2

Wildcard DNS records are configured for example.com on the China Unicom, China Telecom, and China Mobile lines:

Host Record

Record Type

Line

Record Value

*

A

China Unicom

1.1.x.x

*

A

China Telecom

1.1.x.x

*

A

China Mobile

1.1.x.x

www

A

Default

4.4.x.x

When users from China Unicom, China Telecom, or China Mobile access www.example.com, the domain name resolves to 4.4.x.x. This occurs because the exact-match record on the default line has a higher priority than the wildcard record on the smart lines.

If you want www.example.com to resolve to 1.1.XX.XX for users from China Unicom, China Telecom, and China Mobile, you need to add a DNS record for example.com with www as the host record on each of the three corresponding wildcard domain name lines, as shown below.

Host Record

Record Type

Line

Record Value

*

A

China Unicom

1.1.x.x

www

A

China Unicom

1.1.x.x

*

A

China Telecom

1.1.x.x

www

A

China Telecom

1.1.x.x

*

A

China Mobile

1.1.x.x

www

A

China Mobile

1.1.x.x

www

A

Default

4.4.x.x

Now, when users from the China Unicom, China Telecom, and China Mobile lines access www.example.com, the domain name resolves to 1.1.x.x.