Impaloo
By:
Impaloo

How to structure DNS records for domains with sub-domains

September 3, 2014 2.6k views

Hey. Let's say I have a domain domain.com.

I want all traffic to domain.com to be redirected to www.domain.com (this redirection is done from my web server).

I also want to have custom sub-domains such as william.domain.com.

As of now, my DNS records looks like this.

Is this the correct way of doing it (notice the trailing dot(s))?

1 Answer

If all your subdomains are at the same IP address as the root domain, the simplest set up is to just create a wildcard CNAME:

Check out this tutorial:

How To Set Up and Test DNS Subdomains with DigitalOcean's DNS Panel

by Assaf Gordon
Here's some documentation on how to set up and test DNS subdomains with DigitalOcean's DNS panel.
  • Won't this make any sub-domain "valid"?

    As in.. you would be able to ping lasjdhajkdasjkd.domain.com. This doesn't seem very nice to me. I don't mind adding a new record for every sub-domain I make.

  • Right. It would do that. The linked tutorial goes over it. There's more than one way to do it. You can uses:

    william.domain.com. IN A 1111.1111.1111

    or

    william IN A 1111.1111.1111

    The key is to use the dot when using a fully-qualified domain name, otherwise it isn't needed.

  • I don't quite fully understand FQDNs.. However, this is my new configuration:

    @   IN A    178.62.33.15
    www IN A    178.62.33.15
    william IN A    178.62.33.15
    

    Now www.domain.com doesn't work.

  • I don't quite fully understand FQDNs.. However, this is my new configuration:

    @   IN A    178.62.33.15
    www IN A    178.62.33.15
    william IN A    178.62.33.15
    

    Now www.domain.com doesn't work.

  • I'd try adding a CNAME record www to william to see if it works.

Have another answer? Share your knowledge.