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 of its intricacies in order to successfully manage them. A basic understanding will cover the majority of the scenarios you’ll encounter.
What are DNS records used for?
DNS was create
d 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.
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.
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.
The A, or Address record, is one of the most commonly 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.yourdomain.com, you would only need to add www for the name value. The yourdomain.com part is automatically assumed.
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.
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.
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.
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 actually 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.
Adding or changing DNS records in cPanel
If you’re using a web 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 effect a fix.
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.