Understanding DNS

by pieterh on 15 Oct 2009 13:38

Setting a custom domain can be a frustratingly technical experience. Today I'll try to walk you through some of the background to the domain name system (DNS) so that you understand better how this works. Thanks to morningbird for asking the question.

The DNS system turns site names into Internet addresses. Every domain has a DNS configuration. When you buy a domain name, you can (depending on your registrar and what they offer you) configure the DNS for your domain.

While DNS has many options, only two interest us here. These two are "canonical name records" and "address records", or CNAME and A.

  • A CNAME record turns a website name into another website name.
  • An A record turns a website name into an Internet address.

There is one more thing you need to learn. That is "domain" vs. "subdomain".
wikidot.com is a domain, while www.wikidot.com is a subdomain. The word "host" is often used to mean "domain or subdomain".

Let's see how these work.

You can use CNAME for subdomains but not for domains. So, for subdomains like 'www.example.com' and 'blog.example.com' but not for 'example.com'. A CNAME record refers to another DNS name, which can be 'wikidot.com' or 'www.wikidot.com' (these are equivalent here). So:

blog 10800 IN CNAME www.wikidot.com.
www 10800 IN CNAME www.wikidot.com.

This is the raw DNS record format. Most web interfaces try to make it simpler for you.

In the DNS configuration you also need at least an A record that tells browsers across the Internet what IP address example.com is sitting at. Which gives us a DNS entry like this:

@ 10800 IN A 107.20.139.170

107.20.139.170 and 107.20.139.176 are the the IP addresses for www.wikidot.com, and you can use either one. It's shown on the site manager Custom Domain page.

Many web clients will try to provide a more friendly A record editor. The '@' stands for 'the domain', thus example.com. The 10800 is the timeout, in seconds, (time-to-live = 3hours) which specifies how long this DNS entry is cached by servers between you and example.com.

Every CNAME record lookup eventually ends up as an A record lookup.

So, what does this mean for your custom domain?

  • If you want to use the hostname (example.com) you must define an A record that points to Wikidot's IP address
  • If you want to use a subdomain (www.example.com) you can define a CNAME record that points to www.wikidot.com

One way for Wikidot to solve this problem is to simply ban the use of hostnames. Other services do this but I find it annoying because it means when people type the hostname without 'www' they land on whatever web site the actual A record points to.

Comments: 5

Add a New Comment