The domain name system (DNS) is a key part of internet infrastructure. It’s a concept that’s simple from a high-level overview, but when you get down into the trenches, it becomes very complex. Webmasters often have to delve into the world of DNS records to solve everyday problems. Fortunately, it’s not necessary to master all its intricacies to successfully manage them. A basic understanding will cover many of the scenarios you’ll encounter.
What are DNS records used for?
DNS was created to solve the dilemma that computers work best with numbers, people not so much. Its basic function is to map names to numbers, like a phone book. As you probably already know, every device, or host, that connects to the internet is identified by number, in the form of an IP (internet protocol) address that looks something like this: 123.456.98.22.
An IP address must be unique within a network. For websites, the network is the entire internet.
In DNS, an individual mapping that links an IP address to a resource is called a resource record. Resource records are collected into zones, which are stored on nameservers.
Here’s a bit more detail on the important DNS terms:
Resource Record (RR)
A resource record is a one-line text description that defines a particular resource. It’s the base unit of the DNS system. A resource record consists of multiple fields separated by whitespace or tabs, in the following generic form:
name ttl class type data
Name: The host name for the record.
TTL: Time to live in seconds. This is the amount of time the record is allowed to be cached. A TTL of 3600 means the record will update every hour. A TTL of 86400 means it will take a day for changes to update.
Class: A value that describes the protocol family being used. Most often, this is set to IN, which means “internet protocol.”
Type: Identifies the resource record type, which is an abbreviation for the type of data stored in the subsequent data field. Examples include A (address) and MX (mail exchange), among others.
Data: The data payload needed for the particular type of record. This part may contain one or more elements separated by white spaces.
We’ll talk more about specific resource record types you may need to work with later in this article.
The resource records pertaining to your domain are stored in a zone file. A DNS zone is a subset of the domain name system, often a single domain. A zone file contains the mappings between IP addresses and names within that subset, in the form of individual resource records that point to different aspects of the domain. It can also contain directives and comments. Your domain’s zone file is stored on its nameserver.
A nameserver is a specialized server that handles queries about the location of a domain name’s services, such as your website or email. You “point” your domain to particular nameservers by assigning them in your domain’s DNS settings. Typically your nameservers will be those of the company you registered your domain with, but not always. A site’s DNS settings will include at least two nameservers, a primary and a secondary. If the primary server isn’t responding, then the secondary server will be used to resolve the request.
Commonly modified DNS records
There are more than 30 types of DNS records that can potentially be implemented. Luckily, just a handful of them are of practical use to most webmasters. Those you’re most likely to encounter include:
CNAME stands for canonical name. A CNAME record is used to redirect from one domain name to another automatically. For example, if you wanted store.yourdomain.com to automatically redirect to your EBay store, you could add a CNAME record to accomplish that. For example:
store.example.com 86400 IN CNAME yourstore.ebay.com
The A, or Address record, is one of the most used record types. It allows you to map a domain name to an IP address. When adding an A record, the domain name is automatically appended to the name you enter. So, for example, if you want to make an A record for www.example.com, you would only need to add www for the name value. The example.com part is automatically assumed. Example:
www 86400 IN A 123.456.78.90
A TXT record allows you to add text data into your DNS records. A common use is ownership verification. For example, if you want to use Google Webmaster Tools, one way of proving you own the domain is to add a TXT record containing a randomly generated string provided by Google. Google then checks to see if the record exists to confirm you control the domain.
example.com 86400 IN TXT randomstring
MX stands for mail exchange. An MX record points to the mail server that should be used to deliver mail for a domain using SMTP (simple mail transfer protocol). MX records always point to a domain, not an IP address. If a domain doesn’t have an MX record, a sending server will attempt to deliver mail to the domain’s A record instead. Example:
86400 IN MX 10 mail.domain.com
Note that an MX record doesn’t list a host name at the beginning. That’s because it applies to the entire zone. The 10 is an extra number that sets the priority of this record if multiple mail servers are defined. Lower numbers have higher priority.
As mentioned earlier, an NS record indicates which server is responsible for processing queries for a domain. If you change hosting to somewhere other than where you registered your domain, you would need to update the NS records.
Example: example.com 86400 IN NS ns1.yourprovider.com
A PTR (pointer) record, also called a reverse DNS record, resolves an IP address to a domain name. This is exactly the opposite of what an A record does. PTR records are mainly used to check if a server name is associated with the IP address from where a connection was initiated. PTR records are often used for outgoing mail servers because many mail providers will reject or mark as spam messages received from servers that don’t have a valid PTR record.
This is a little more complicated than simply adding a DNS record as a reverse zone must be set up first. GoDaddy administrators configure reverse DNS on all their email servers. If you use another provider, contact the provider of your IP address for help configuring reverse DNS.
Adding or changing DNS records in cPanel
If you’re using a hosting plan with cPanel, and decide to point your domain at your host’s nameservers, you’ll need to use cPanel to manage the DNS records. In cPanel, you’ll find an icon for the DNS Manager under the Domains section. Clicking on that will get you to where you can edit the records.
When changing DNS records, remember that there’s a lag time before the change will actually take effect. That lag time is defined by the TTL value set for the record.
For that reason, it’s a good idea when editing DNS records to first go in and temporarily reduce the TTL time. Once that change takes effect, you can make your final edits. This way, your change occurs more quickly, and if you make a mistake when entering your final record, you won’t have to wait hours or days to affect a fix.
Editor’s note: Should you use your domain registrar, or should you use your hosting provider to manage DNS records? That’s entirely up to you, and there are pros and cons to both approaches. Using your registrar’s nameservers lets you manage all domain configuration in one location. But if you use a lot of addon domains or subdomains in your hosting plan, your host’s nameservers will automatically configure the corresponding DNS records.