Wildcard broke after adding a TXT record
I've been using a wildcard on my domain to catch and redirect any random subdomains a person might try:
*.mydomain.com
But when I recently added a TXT record it broke the wildcard's ability to catch that name:
dig @ns1.linode.com +short txt dev.mydomain.com
"devTEST"
dig @ns1.linode.com +short A dev.mydomain.com
Empty Response
How can I make the subdomain work again?
2 Replies
A wildcard will always come second if a “real” record exists. So because you added a TXT record, the DNS system will now only serve that. To get around this you need to add a subdomain which uses the same name as the TXT record. Once done you’ll get the expected results and your wildcard will continue to catch everything else.
dig @ns1.linode.com +short txt dev.mydomain.com
"devTEST"
dig @ns1.linode.com +short A dev.mydomain.com
127.0.0.1
You won't often use a TXT record with the same value as a subdomain so this isn't normally an issue, but you'll need to keep this in mind if you ever design a setup like that.
A wildcard will always come second if a “real” record exists.
From my experience with other systems (mainly PowerDNS) is that A
wildcard will only get overriden by A
record, not by TXT
record, which is why I was confused by the behaviour.
You won't often use a TXT record with the same value as a subdomain so this isn't normally an issue
The use case here was just Google site verification, dunno if that's "rare" use case