When you type "mail.example.com" into a Web browser, your browser silently queries a domain name system server. The DNS server returns the IP address of the Web server assigned to that subdomain. When you purchase a domain, you are responsible for configuring either an address record or a canonical name record on the DNS server at your domain registrar. Add an A record when you configure the root domain or if you have an IP address for a subdomain's Web server. Add a CNAME record for a subdomain that points to another domain or subdomain name.
Domains and Subdomains
When you register a domain such as "example.com," the top-level domain, or TLD, is "com" and the second-level domain is "example." A third-level domain, or subdomain, includes another name to the left of the second level, separated by a dot. For example, "mail.example.com" is the mail subdomain of example.com. Subdomain names can only contain the letters A to Z, the numbers 0 to 9 and the hyphen character. A fully qualified subdomain name, which includes three levels and the periods that separate them, cannot exceed 67 characters.
When you configure the Web server address for the root domain, you must add an A record, which is sometimes called a host record. An A record must contain a specific IP address for the destination server that the root domain points to. If you have one or more subdomains that point to the same server as the root, or if the subdomains point to a different server that has a specific IP address, add an A record for each subdomain and provide the appropriate server's IP address.
If you use a third party to host applications that you want to access through a subdomain, you might have to point the subdomain to another domain name instead of an IP address. This requires a CNAME record, also called an alias, instead of an A record. For example, to point "calendar.example.com" to the Google Apps calendar program, create a CNAME record for "calendar.example.com" and "ghs.googlehosted.com." The name you configure must ultimately reconcile to an IP address to reach the server. A CNAME record can also point directly to an IP address.
While you can type any name for a subdomain, the only valid subdomains are those with a DNS record. When a user types a subdomain without a DNS entry, he usually receives a "Server Not Available" message, or something similar. Alternatively, you can use the subdomain to pass information to the Web server by entering an IP address and using the asterisk wildcard, such as "*.example.com." The wildcard directs any subdomain to the IP address provided. When traffic arrives, the server can determine how to handle the traffic based on the subdomain the user typed.
- DNSimple.com: Differences Between the A, CNAME, ALIAS and URL Records
- Easy DNS: A Records and CNAMEs
- The University of Texas at Austin: Understanding How Domain Names Work
- Google: CNAME Record Values
- HostGator: Wildcard DNS -- What Is It and How Do I Use It?
- KBeezie.com: Handling Wildcard Subdomains With PHP
- Photo Credit deyangeorgiev/iStock/Getty Images