Wildcard for A and MX records possible?

I'm building an app where each customer can have their own subdomain. For this example, he setup his subdomain to be: whisky

I created a wildcard subdomain in my DNS:

*.myapp.example A 192.0.2.123

So when he accesses my webapp, he would use the URL: whisky.myapp.example and it would resolve to 192.0.2.123.

My app also sends email (email will be handled by sendgrid) using the same subdomain my customer chooses: e.g. [email protected]

But when I tried to setup a wildcard MX record to sendgrid's servers, my DNS provider does not allow me to do so, citing some standards violation.

e.g. *.myapp.example MX sendgrid.com

Is there any way I can have wildcard subdomains for both?


Solution 1:

RFC1912 explicitly acknowledges the existence of wildcard MX records, but warns

A wildcard MX will apply only to names in the zone which aren't listed in the DNS at all.

RFC4592 is a standard-track RFC that clarifies the existence of MX wildcards (see the example in section 2.2.1). I'm pretty sure your DNS provider is, thus, full of it.

I can imagine some DNS software having trouble with the situation, too, either because they don't support wildcard MX records at all, or because they take the "no other records" thing a bit too literally and don't allow both a wildcard MX and a wildcard A. This software is non-standards-compliant, but good luck getting that fixed.

Given how trivial it is (or should be) to automatically setup DNS records when customers sign up, I'd skip the wildcards entirely and just have your app configure DNS records for each customer.