I need to set a wildcard DNS record for a sub domain which already has an A record. I'm not sure if i have to use a new A record for this or can just use a CNAME that points to the A record.

My script has the following domain structure

  • {random_code} - We use random code as a solution against browser implemented HTTP socket limits. (only used for loading dynamic elements onto a page - as such it can only be viewed by viewing the source of a web page while the URL in a users browser only shows the location subdomain)
  • {location_subdomain} - We load content from our closest server to the user, so each location has an A record that points to a different server (content across all our location servers are 1:1).
  • {domain.com} - Points to our front end server which hosts our index page
  • {path} - self exploratory

Current DNS zone file

domain.org. 86400   IN  NS  dns1.domain.org.
domain.org. 86400   IN  NS  dns2.domain.org.
domain.org. 86400   IN  NS  dns3.domain.org.
domain.org. 86400   IN  NS  dns4.domain.org.
domain.org. 14400   IN  A
localhost   14400   IN  A
www     14400   IN  CNAME   domain.org.
ftp     14400   IN  A
france  3600    IN  A
phoenix 3600    IN  A
nl      3600    IN  A
*       14400   IN  A

But i need to add a wildcard for each location A record that points to the same address. So for example {randome_code}.phoenix.{domain.com} would point to while still making sure phoenix.{domain.com} still points to the same IP.

Do i just have to create new A records like this for each location while keeping the non wildcard records as well?

*.france    3600    IN  A
*.phoenix   3600    IN  A
*.nl        3600    IN  A

I was under the assumtion that this would be an extra lookup so i thought i would be able to use a CNAME but im not sure the proper format to add a wildcard CNAME record that points to an already created A record while still keeping the original wildcard working so that any lookup that are not using a location subdomain would still be answered with our front end web server address.

Or do i have this completely wrong, can i not have a wildcard on the root domain as well as on A records ?

  • Does this belong in webmasters, should i have posted it there ?
    – Analog
    Mar 29, 2015 at 18:11

1 Answer 1


What you have there:

*.france    3600    IN  A

will work exactly as you're expecting; a query for abc.france.example.com will get the answer from the wildcard A record, while france.example.com will still be getting its data from france 3600 IN A

No extra lookup is needed, as you're not doing additional delegation.

If it's easier for you to manage, you can also use a CNAME:

*.france    3600    IN  CNAME   france

A CNAME can typically cause an extra lookup, but in this case it won't; the record being referred to is in the same zone, so your DNS server will respond with the "answer" of the CNAME, as well as including the relevant A record for france.example.com.

  • I don't know if the wording is just a coincidence or if you meant to imply that the A record would be returned in the additional section? Anyway, it's returned in the answer section, together with the CNAME record. Mar 29, 2015 at 19:47
  • @HåkanLindqvist You're right, I was thinking NS record behavior - corrected. Mar 29, 2015 at 19:49
  • Perfect thank you for the explanation, i will be using a CNAME then.
    – Analog
    Mar 30, 2015 at 17:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.