Step-by-Step: Writing a Zone File with a Subdomain
Updated: May 4, 2001


Note: This example is specific for using the GraniteCanyon.com free DNS service.  However, it can be adapted to work with any DNS service if you replace "ns1.granitecanyon.com" and "ns2.granitecanyon.com" in lines 1 and 2 with the names of the nameservers you are using.

This article assumes that you already looked at How to write a zone file beforehand.  All we are going to do here is add a subdomain.

You might want a subdomain for several reasons.  You can use it to access a part of your website faster.  For example, www.dslwebserver.com leads to the main site and you can enter the forums by clicking on the icon labeled "forums".  However, the good people at DSL/Cable Webserver know that some people want to go directly into the forums without going through the main site so we created a subdomain called "forums".  This way, you can go into our forums by simply typing in forums.dslwebserver.com.  Pretty cool and handy.

Another reason you might want to use subdomains is so that you can host somebody's website under your domain name.  Something like this:

  • jack.dslwebserver.com
  • jill.dslwebserver.com
  • jessie.dslwebserver.com
You could set it up so each of those subdomain + domain names go to each person's website.  Very nifty.

There are two ways we can setup subdomains.  We can set the subdomain to go to:

  • Option 1. The same IP address as the domain name.
  • Option 2. A different IP address than the domain name.
Most of us hosting websites on DSL or Cable only have 1 IP address so Option 1 is probably more applicable to us.  In order to host subdomains on the same IP address, your webserver software must be able to host multiple websites on a single IP address.  A list of the operating systems and webserver software that can do this can be found in Server Software.

In each instance, you must add a new line in the zone file for each additional subdomain.  This should be obvious.

Once you are done writing your zone file, go and upload it to your DNS company.  Here is How to Upload a Zone File at GraniteCanyon.com.  After your DNS changes are complete, you must configure your webserver software to work with subdomains.

Cut and past the text in the yellow boxes and use the "replace" function in either Notepad or Microsoft Word to do your replacements. It will save you time and be more accurate.


Here is the generic zone file for reference.
yourdomain.com. IN NS ns1.granitecanyon.com.
yourdomain.com. IN NS ns2.granitecanyon.com.

yourdomain.com. IN RP yourname.yourdomain.com. yourdomain.com.

yourdomain.com. IN A xxx.xxx.xxx.xxx

www.yourdomain.com. IN CNAME yourdomain.com.
ftp.yourdomain.com. IN CNAME yourdomain.com.

localhost.yourdomain.com. IN A 127.0.0.1

yourdomain.com. IN MX 10 yourdomain.com.

Replace yourdomain with your domain name
Replace xxx.xxx.xxx.xxx with your IP number
Replace yourname with your own name


Option 1:
Here is the zone file where the subdomain has the SAME IP address as the domain name.
yourdomain.com. IN NS ns1.granitecanyon.com.
yourdomain.com. IN NS ns2.granitecanyon.com.

yourdomain.com. IN RP yourname.yourdomain.com. yourdomain.com.

yourdomain.com. IN A xxx.xxx.xxx.xxx

www.yourdomain.com. IN CNAME yourdomain.com.
ftp.yourdomain.com. IN CNAME yourdomain.com.
subdomain.yourdomain.com. IN CNAME yourdomain.com.

localhost.yourdomain.com. IN A 127.0.0.1

yourdomain.com. IN MX 10 yourdomain.com.

Replace yourdomain with your domain name
Replace xxx.xxx.xxx.xxx with your IP number
Replace yourname with your own name
Replace subdomain with your desired subdomain name


Option 2: 
Here is the zone file where the subdomain has a DIFFERENT IP address than the domain name.
yourdomain.com. IN NS ns1.granitecanyon.com.
yourdomain.com. IN NS ns2.granitecanyon.com.

yourdomain.com. IN RP yourname.yourdomain.com. yourdomain.com.

yourdomain.com. IN A xxx.xxx.xxx.xxx
subdomain.yourdomain.com. IN A ZZZ.ZZZ.ZZZ.ZZZ

www.yourdomain.com. IN CNAME yourdomain.com.
ftp.yourdomain.com. IN CNAME yourdomain.com.

localhost.yourdomain.com. IN A 127.0.0.1

yourdomain.com. IN MX 10 yourdomain.com.

Replace yourdomain with your domain name
Replace xxx.xxx.xxx.xxx with your IP number
Replace yourname with your own name
Replace subdomain with your desired subdomain name
Replace ZZZ.ZZZ.ZZZ.ZZZ with the IP number of your subdomain



Once you are done writing your zone file, go and upload it to your DNS company.  Here is How to Upload a Zone File at GraniteCanyon.com

After your DNS changes are complete, you must configure your webserver software to work with subdomains.
 



Step by Step Menu