Web Hosting 101, part 2: Domain Name Services

Editor’s Note: This is the second installment of a three-part series on web hosting. See author Patrick McNeil’s previous article:

In the first part of our Web Hosting 101 series, I tackled domain names—how to choose a domain name, how to register a domain and how to manage privacy. Part 2 is going to be the most technical of the three articles in the series, but it’s also one of the most important and empowering. Hang with me, and I promise to keep it on target and as narrowed down to the core nuggets as possible.

What is DNS?

DNS stands for Domain Name Services. DNS is the system used by your computer to translate a pretty domain name into an IP address. Domain names are only there for the convenience of humans by giving a meaningful descriptor to an IP address. And IP addresses are the real way the web is navigated (by the computer). The easiest way to think of this is like a GPS system: Your house has a mailing address, but that doesn’t mean anything to a GPS device. Instead, it tracks the latitude and longitude of your house. Behind the scenes, your GPS is working with numbers; it just puts a pretty face on them for the user’s sake. IP addresses work exactly the same way. Here’s the real nugget to remember: DNS is the glue that connects your domain to a host.

Hostnames

Before we dig too deep into DNS, let’s clarify one thing: DNS doesn’t point domain names, it points hostnames. Let’s start with a few examples of valid hostnames for my personal domain name:

  • pmcneil.com
  • www.pmcneil.com
  • mail.pmcneil.com
  • www2.pmcneil.com
  • anything-i-want.pmcneil.com
  • many.sub.domains.pmcneil.com

All of these are valid hostnames that can be used in conjunction with the domain name pmcneil.com. We can point each hostname to a distinct IP address; we could point them all to the same IP address, or any mix in between.

Patrick McNeil Homepage for web hosting series

It’s most common to point the root hostname (pmcneil.com in this example) to the same location as the www hostname (www.pmcneil.com in this example) to the exact same IP address. This is why for most sites you can either omit the “www” or use it and get the same website. Some sites are mistakenly setup so that one of these doesn’t work (typically the one without “www”) or they accidently point to different sites. So, when you have a domain name you can create as many hostnames as you like and point them any place you like. The real beauty of this is that hostnames are free.

Subdomains

One point of confusion related to hostnames is the term subdomain. When we refer to a subdomain, we’re simply identifying a portion of a hostname—namely, everything added in front of the domain name. An example is probably the easiest way to demonstrate this. Consider the following hostname: www.pmcneil.com In this case the full string is the hostname, the domain name of course is “pmcneil.com” and the subdomain is “www”. Again, everything placed in front of the domain name. From the samples of hostnames above we can identify various subdomains like: intranet, mail, www2 etc. On a domain we own, we can create all the subdomains we like. This is a great way to setup test sites, special promotion sites that you want to associate with a site, but don’t want a new domain for, and so on. For example, universities make good use of subdomains. Typically just about every website that is a part of a university will share a common domain. Through the use of a mountain of subdomains you will find all sorts of sub sites. For example, I attend depaul.edu and I happen to be enrolled in the CDM department, which has the subdomain http://www.cdm.depaul.edu. Note how they included the “www” in front of the subdomain as an additional layer. (I suspect this was done to accommodate for people that type in the www even when they don’t need it.) Note that if you load http://cdm.depaul.edu, you get the same site, because both hostnames point to the same IP.

Setting Up DNS

So DNS is the road map that controls where my domain and subdomains point to, but how do I set it up? When you register a domain you have to specify what are known as name servers. These name servers are the places that store your DNS records and tell the world how to find your site. If you register your site with an all-in-one service such as GoDaddy, where they also registered the domain for you, then this was all set up for you. However, if you use a registrar separate from your web host, then you’ll have to manually configure this part of the puzzle. It might sound complicated, but at the end of the day all your are doing is creating a list of records. Each record has three bits of simple data:

  1. The record type
  2. Typically a hostname
  3. Typically an IP address

There is some minor variation in this, but overall these are the three pieces you have to work with. If you’re a DNS genius you might find this simplification frustrating, but for those of us that just need to get a site working, it is more then sufficient. One of the most critical concepts to recognize here is that DNS is nothing more than a list of records. We can easily create them if we just know what we’re looking for. One of the most important concepts to polish off this knowledge is a brief introduction to three critical types of DNS records.

3 Types of DNS Records

The three types of records we need to briefly cover are: hostnames, CNAMEs and MX records.

Hostname records

Now, we already know what a hostname is (a pretty name for an IP address). And a hostname record is nothing more than a hostname and the IP address it points to. This is the most common type of DNS record that you’ll need to create. One important note is that hostname records are also frequently referred to as “A records.” In many systems, I see them used intermittently. On one page it might say “add a hostname” and on the next it will say “add an A record.” This can be confusing. Just know they are the exact same thing—tomato, tomahto.

CNAME records

CNAME records are another common tool. A CNAME is a pointer to another hostname. What you can do is create a new hostname in your CNAME, and rather than point it to an IP address, you point it to another hostname. In essence, you’re saying that this hostname goes where ever that other hostname says. You will frequently find this in situations where you’re using a hosted CMS that allows you to setup a custom domain name. Tumblr is a perfect example, and if you look at their instructions you might find that you suddenly understand them a lot better. CNAMEs are particularly useful when you need a lot of people to point domains to a single location. By having them use a CNAME instead of an A record where the IP is explicitly stated, you create a lot of flexibility. For example, say the hosted CMS company needs to set up a new server and wants to quickly migrate users over. If everyone used a CNAME they can simply update the main record and every CNAME record that points to that host is magically sent to the new one. Imagine instead if thousands of people use the actual IP address. You would have to have everyone update their DNS to make the move.

MX Records

Finally let’s consider MX records. An MX record is very similar to a hostname record. It points a valid hostname to an IP address (and in some cases, it points to another hostname). The difference is rather simple. Instead of being used to route web traffic it is used to route e-mail. MX records define where e-mail for your domain (and subdomains) is to be sent. The IP address being an e-mail server configured for your domain. I point many people to Google Apps to host their e-mail, and one of the steps required to set this up is to create some MX records for your site (as seen here). Here you can see that e-mail is being set up to point to Google servers. When you create these records you would use your hostname. For example I used “pmcneil.com” as my hostname to point to the Google servers when I was setting up my MX records. I know this part of the puzzle is the most technical, and if you don’t have to do this today it might be a bit much. However, if you find yourself faced with configuring some DNS records, I hope this guide sheds some light on how it works and what it all means. Next up is the final part in this series where I discuss your options for web hosting.

Want to learn more about web hosting? Check out the next installment in this series for web designers:

More Technical Resources for Web Designers

COMMENT