This article first appeared here Ask Question Asked 12 years, 10 months ago Modified 2 years, 7 months ago Viewed 240k times 137
I’m making a website, and I need a sub-domain.
I need to add the new part to my website, but I don’t know which type of DNS record to add in the DNS console to point to this new site.
Is it A
or CNAME
?
edited Dec 12, 2016 at 13:34 asked May 29, 2011 at 16:17
Keavon 1,47122 gold badges99 silver badges77 bronze badges
4 Answers
It depends on whether you want to delegate hosting the subdomain off to a different DNS server (or to the same server, but in a different zone file). You delegate a zone when you want some other entity to control it, such as a different IT department or organization.
If you do, then you need NS records. If not, A or CNAME records will suffice.
Let’s say you have the domain example.com. You have an A record for www.example.com and you want to create the subdomain info.example.com with www.info.example.com as a host in it.
Delegation
In the this situation, let’s further say you have two DNS servers that will be hosting that subdomain. (They could be the same servers that are currently hosting example.com.) In this case, you will create two NS entries in the example.com zone file:
info IN NS 192.168.2.2
info IN NS 192.168.2.3
On those two servers, you will create the info.example.com zone and populate it as you would any other domain.
www IN A 192.168.2.6
No delegation
Here, just add an A record in the example.com zone file, using a dot to indicate that you want to create the www.info
host in the example.com
domain:
www.info IN A 192.168.2.6
Using CNAME
The decision of whether to use a CNAME is independent of the delegation choice. I generally like to use a CNAME for the “generic” names which point to specific machine names. For example, I might name my machines using an organizational naming convention such as cartoon characters (daffy, elmer, mickey, etc.) or something bureaucratic (sc01p6-serv) and point the generic names to them. If the IP address of the machine ever changes, I need look in only one place to modify it.
www IN CNAME sc01p6-serv
mail IN CNAME sc01p6-serv
sc01p6-serv IN A 192.168.2.6
To delegate the entire subdomain to another DNS service, you need the following records in your hosts DNS:
- two Name Server (
NS
) records pointing to the authoritative name servers for your sub-domain - Address (
A
) records for the sub-domain name servers
And you need to provide a pair of DNS name servers for your sub-domain. They need to serve the following records:
- a Start of Authority
SOA
record for the sub-domain - two or more
NS
records A
records for the sub-domain name servers
RFC1034 contains a good description of how sub-domains are configured.
26022 silver badges1111 bronze badges
answered May 29, 2011 at 16:43
D.Shawley The answer is, either will work.
Which is preferred should be advised upon by your web host.
If they’re in the habit of changing the IP addresses of their servers, use a CNAME
pointing to the name they tell you.
Alnitak If your host gives you a name in another domain, you need to create a CNAME in your domain, if your host gives you an IP address, you need to create an A record in your domain.