Basics of DNS • How to setup DNS records

Basics of DNS

DNS or Domain Name System is a pointer system, this system points a domain name to an Internet Protocol (IP) address. When user types any domain name say www.example.com in his browser and hits enter, a query is made to the local DNS servers (generally your ISP) and this queries other DNS servers to find the record you requested. The responsible DNS server for your requested domain resolves it to the IP address like 76.226.193.63 and your requested website is displayed on the browser. This full process is known as DNS resolution.

Introduction to DNS

How DNS Works

The DNS works in the background and is responsible for delivering the results of all the domain name queries made in your browser. It simplifies the connection of domain name with the IP address, hence you do not need to remember IP addresses as it is easier to remember the domain names. So you can call DNS as internet’s phone book directory, they maintain the directory of domain names and translate them to IP addresses. This is an important function as any computer connected on the internet is identified by IP address.

How to setup DNS records?

Once you have registered your web hosting you will receive a mail from your web host asking you to setup the nameserver records to make your website live.

Nameserver records

A nameserver keeps the record of your domain’s DNS entries. For example if your domain is hosted with Rackspace your nameserver record will be the Rackspace’s DNS records as mentioned below

Primary Nameserver: NS.RACKSPACE.COM
Secondary Nameserver:NS2.RACKSPACE.COM

Each domain name should have at least 2 nameservers The Primary nameserver and secondary nameserver. If in case the primary server is not responding the secondary nameserver will resolve the domain name. Some hosting providers even have 3 nameservers. You will need to set these records in your domain control panel. The records could take approx. 24 hours or less to propagate. Once DNS propagation is complete you can manage any custom DNS records from your hosting DNS control panel.

The TTL is a setting for each DNS record that specifies how long a resolver is supposed to cache (or remember) the DNS query before the query expires and a new one needs to be done. For critical records which change often, you can set the TTLs as low as 300 seconds or 30 seconds. For non-critical records that rarely change you can set the TTLs between 4 hours to 1 day. A thumb rule is never set the TTLs for more than 1 day (or 86400 seconds which is 24 hours).

The Nameserver DNS records rarely change hence you can set the TTL (or Time to Live) to 86400 seconds.

A and AAAA (IPV6) Records

Generally your hosting provider will set up your A or AAAA records by default which will point to your domain name www.example.com. The A record shows as below in your DNS zone panel

A record

A record setting

You can set the TTL for A records to 4 hours ie 14400 seconds.

MX records (or Mail Exchange records)

The MX record describes how your email will be handled. For setting up this record you will first need to set an A record, and then associate an MX record with it. The records can be set as below

MX record setting

MX record setting

In the above example, we have set up 2 MX records with preference 10 and 20. The lower MX record will have the first priority and will allow mail exchange and if this record is down due to some reason then the higher preference record will be used for mail exchange.

Generally the MX records are preset if you are using your hosting provider’s mail servers. In case you have your own mail servers you can point them accordingly. Since you are not going to change the MX records frequently I would suggest you to keep the TTL to 86400 seconds.

TXT records

The TXT record has a host name and you can assign the text to this particular hostname. The TXT record is commonly used to store SPF (sender policy framework) records. Sender Policy Framework (SPF) records allow domain owners to publish a list of IP addresses or subnets that are authorized to send the email on their behalf. The goal is to reduce the amount of spam and fraud by making it much harder for malicious senders to disguise their identity. The TXT records can also be used as verification for Google Apps or Microsoft Office 365. Sample of SPF record would look like below

TXT record setting

TXT record setting

You can keep the TTL for these records to 86400 as they do not often change.

CNAME records

A canonical name or CNAME is a DNS record that maps an alias name to a fully qualified host name.
For example you have a server where you keep all your photos, it might normally be accessed through pics.example.com. You may also want to access it through photos.example.com. One way to make this possible is to add a CNAME record that points photos.example.com to pics.example.com. When someone visits photos.example.com they will see the exact same content as pics.example.com. Refer below how the settings are done

CNAME record setting

CNAME record setting

You can keep the TTL as 86400 as this record does not change often.

I would like to give you one tip which has been useful for me when I make DNS changes. If you plan to make DNS change then, lower the TTL value for the record to 300 seconds atleast 48 hours before you make the DNS change. This will allow the lower TTL value to propagate throughout the DNS and will allow for faster DNS propagation after you have actually changed the DNS record.

I have provided some basic DNS information above which would be useful for beginners. One good free tool for checking DNS records is http://network-tools.com/ which I often use. I wish you have found the above information on DNS useful, kindly share your thoughts on the same.

Get more stuff like this

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

Leave a Reply

Get your Cheat Sheet and more stuff like this
in your inbox

Enter your email address and click the button below to get your free Cheat Sheet.