Using DNS to Forward All Subdomains

DNS is used to translate domain names into IP addresses. If you have ever owned a domain name, you have probably had to mess with DNS at least a little bit. In this article, I will tell you about forwarding all of your subdomains using a wildcard in your A (Host) DNS records.

Why:

Here are some situations where this would be useful:

  • If you plan on using multiple subdomains pointing to the same server (and using your web server to handle them)
  • If you want to redirect all subdomains to www or the root address of your domain
  • If you want to redirect all subdomains not in use to somewhere

How To:

  1. Create a new A (Host) DNS Record
  2. For host, input * (this may be different depending on your DNS provider, I use GoDaddy)
  3. For ‘Points To’, input the desired destination IP Address

Voila! You may have to wait a while and flush your local dns.

Notes:

The wildcard is only used after all other records have been checked. All A (Host) and CNAMES(Aliases) records will be used before resorting to the wildcard. This is great if you need a few exceptions.

My next article will explain how to handle multiple domains and subdomains on the same ipaddress and server using apache.

Leave a Reply