Now that you've set up a Linode and started hosting a website, it's time to point a domain name at your server and your website. To do that, you'll use something called the Domain Name System (DNS), which is the Internet's address book. DNS is responsible for directing web traffic to your Linode and emails to your inbox. It maps memorable domain names like example.com to IP addresses like 184.108.40.206. This guide explains how to create basic DNS records for your website, introduces some advanced DNS configurations, and provides basic troubleshooting steps.
Before adding any DNS records, you should learn the basics of DNS. This section explains how DNS and domain names work. You'll start by dissecting a domain name, and then you'll learn about the mechanics of DNS resolution, including name servers, zone files, and individual DNS records.
Everyone's familiar with domain names, but there's more to some domain names than meets the eye. Domain names are best understood by reading from right to left. The broadest domain classification is on the right -- the classifications become more specific as you move to the left. In the examples below, the top-level domain, or TLD, is .com.
Every term to the left of the TLD and separated by a period is considered a more specific subdomain, although conventionally, first-level subdomains plus their TLDs (example.com as shown above) are referred to as "domains." Moving to the left, hello and mail are the second- and third-level subdomains, respectively. Typically, subdomains are used to uniquely identify specific machines or services, but this is left up to the domain owner.
Choosing and specifying name servers is an essential part of domain ownership. If you don't, the Internet won't know where to find your DNS information, and your domain won't resolve. Name servers host a domain's DNS information in a text file called the zone file. They're are also known as Servers of Authority (SOAs). You can host your DNS information on name servers in one of several locations:
Using Linode's free name servers is the easiest approach, because Linode provides a default zone file with all the right IP addresses for your website and email. For basic DNS setups and many advanced ones, Linode's name servers will work beautifully. However, you can also look into the options offered by your registrar and third-party DNS hosts. You can host your own DNS if you want to take control of as much of the DNS process as possible.
You'll specify name servers on your domain registrar's website. They'll take care of publishing that information to the higher-level name servers. You'll want to specify at least two name servers. That way, if one of them is down, the next one can continue to serve your DNS information.
The next aspect of DNS management is specifying DNS records, which actually match domain names to IP addresses. The DNS records are then automatically bundled up into a zone file, which is what allows the Internet to look up the correct IP address for your domain. If you decide to use Linode's name servers, our DNS Manager will help you create a default zone file. It contains the following records:
; example.com  $TTL 86400 @ IN SOA ns1.linode.com. admin.example.com. 2013062147 14400 14400 1209600 86400 @ NS ns1.linode.com. @ NS ns2.linode.com. @ NS ns3.linode.com. @ NS ns4.linode.com. @ NS ns5.linode.com. @ MX 10 mail.example.com. @ A 220.127.116.11 mail A 18.104.22.168 www A 22.214.171.124
Every domain's zone file contains the admin's email address, the name servers, and the DNS records. Of course, you are not limited to these default entries. You can create a variety of DNS records for as many different subdomains as you wish. To learn how to add individual DNS records using the DNS Manager, read this article.
So how does DNS actually work? First, the domain name needs to get translated into your Linode's IP address. DNS matches human-friendly domain names like example.com to computer-friendly IP addresses like 126.96.36.199. This happens in a special text file called a zone file, which lists domains and their corresponding IP addresses (and a few other things). A zone file is a lot like a phone book that matches names with street addresses.
Here's how the DNS lookup process works:
The scenario described above is what happens if the ISP has no current information about the requested domain. In actuality, ISPs cache a lot of DNS information after they've looked it up the first time. This results in faster lookups and less strain on DNS servers. Usually caching is a good thing, but it can be a problem if you've recently made a change to your DNS information, like when you move to Linode from a different hosting provider. In those cases, you'll want to pay attention to your zone file's time to live (TTL) so that your DNS change happens as quickly as possible.
If you've uploaded a website to your Linode and registered a domain name, you'll need to point that domain at your Linode so visitors can actually see the new website. Fortunately, Linode provides customers with a comprehensive DNS management interface called the DNS Manager. It's free and easy to use. This section provides step-by-step instructions for adding DNS records to the DNS Manager.
Here's how to add DNS records:
Log in to the Linode Manager.
Click the DNS Manager tab.
Select the Add a domain zone link. The form shown below appears.
In the Domain field, enter your website's domain name.
In the SOA Email field, enter the administrative contact email address for your domain.
Select the Yes, insert a few records to get me started button.
Click Add a Master Zone. Several DNS records will be created for your domain, as shown below.
Log in to the control panel for your domain at your registrar (the company where you bought the domain).
If your domain is currently directing web traffic or email to another server, you'll want to make sure your transition to Linode is as smooth as possible. We recommend modifying the domain's current zone file to lower the TTL (time to live) on all of your DNS records. This will speed up any DNS changes you make later. We recommend that you wait 24-48 hours for the lower TTL to take effect before changing your name servers.
You've now added DNS records for your domain. DNS changes can take up to 24 hours to propagate through the Internet. Be patient! Once the DNS changes are completed, you'll be able to access your website by typing the domain name in to your browser's address bar.
You just finished setting up forward DNS resolution, which allows networks to determine the IP address associated with a domain name. Now you need to configure reverse DNS, which is the inverse process. Here's how to set the reverse DNS on your Linode:
You have successfully set up reverse DNS for your domain name. Visit the linked article to learn how to reset your reverse DNS.
It's possible to have different IPs (including both IPv4 and IPv6 addresses) that have the same domain set for reverse DNS. To do this, you will have to configure multiple A or AAAA records for that domain that point to the various IPs.
At this point, you've created DNS records and set up reverse DNS, but there's a lot more you can do with Linode's DNS Manager. Keep reading if you need to set up subdomains, multiple domains, multiple Linodes, or third-party email. If you need more information or step-by-step instructions on setting up these configurations, see our DNS Manager guide.
To configure DNS for a subdomain, create an A record with the hostname of the desired subdomain. For example, to create hello.example.com, you would enter hello as the subdomain. The A record should point to the IP address of the your Linode (or other server).
You can configure Apache to display websites for subdomains. For more information, see Configuring Name-Based Virtual Hosts.
You can host multiple domains on a single Linode. Just point A records for all of the domains to your Linode's IP address. You can set up virtual hosts so the different websites are displayed correctly for the different domains.
To point one domain at multiple Linodes, point your primary domain (e.g., example.com) to the IP address of one Linode. This machine will serve as the front end for all the others. Then, set up different subdomains (e.g., database.example.com) for the other Linodes, and point each subdomain to the appropriate IP address. The front-end Linode can serve as a proxy for services provided by the other Linodes.
Having problems with your DNS records? We recommend reviewing this section to help get your DNS settings back on track. Follow these tips to troubleshoot DNS issues.
If you've just made a DNS change and aren't seeing it reflected yet, try waiting 48 hours. DNS updates will take effect, or propagate, within the time period set by your zone file's TTL. In some cases, though, the new information may not be reflected for up to 48 hours.
While you can't control DNS caching at every point on the internet, you do have control over your web browser. Try holding down the Shift key or the Control key (depending on your browser) while you refresh the page to bypass your browser's cache of the old DNS data. You can also try bringing up your site in an alternate browser.
Time to Live (TTL) tells Internet servers how long to cache particular DNS entries. The default TTL for Linode zone files is 24 hours, which is pretty typical. (TTL is always written out in seconds, so 24 hours = 86400 seconds.) This is fine for normal DNS situations, because most people don't update their IP addresses all that often.
However, there are times when you'll want the TTL to be as low as possible. For instance, when you make a DNS change, you'll want that change to propagate quickly. Otherwise, some people will see the new site right away, and others (who had the old data cached) will still be visiting the website at your old server. Long caching times can be even more problematic when it comes to email, because some messages will be sent to the new server, and some to the old one.
The solution is to lower your TTL before making a DNS change. You'll want to lower the TTL first, on its own, before making any other DNS changes. Here's a general overview of what should happen during a smooth DNS update:
Sometimes, you just need to find the current DNS information for a domain. There are two great tools for doing this:
If you're using a computer that runs Mac OS X or Linux, you can use these tools from the command line. To find your domain's IP (the primary A record), run this command:
Look in the answer section of the output to locate your IP address. You can also query for other types of records. For example, to see the mail records for a domain, run this command:
dig mx example.com
This returns all of your domain's MX records.
To find your domain's registrar and nameserver information, run this command:
This generates a large amount of information about the domain. The basic information you need will be near the top of the output, so you might have to scroll back to see it.
If you're on a Windows machine, or you're just more comfortable using a web-based tool, you can also use kloth.net for dig requests and whois.net for WHOIS requests. Note that since you're running these lookups from a third-party website, the information they find is not necessarily what your local computer has cached. (There should be a difference only if you've made recent changes to your DNS information.)
You may wish to consult the following resources for additional information on this topic. While these are provided in the hope that they will be useful, please note that we cannot vouch for the accuracy or timeliness of externally hosted materials.
This guide is licensed under a Creative Commons Attribution-NoDerivs 3.0 United States License.
Last edited by Sharon Campbell on Monday, April 7th, 2014 (r4376).