What is DNS?
DNS (Domain Name System), is the service which translates between Internet names and Internet addresses. Internet names are the names which we use to refer to hosts on the Internet, such as www.cpanelkb.net. Internet addresses are the numbers which routers use to move traffic across the Internet, such as 220.127.116.11
What is DNS resource records?
DNS records or Zone files are used for mapping URLs to an IPs. These records are located in the DNS server. It connects your website with the outside world. When the URL is typed on the browser it is being forwarded to your DNS servers and then get pointed to webservers.
DNS server configuration file path is /etc/named.conf
Domains DNS zone files available on your cpanel server.
cPanel DNS Zone file and Records
WHM -> DNS Function
The following DNS Records are mostly used in your cpanel.
Address Mapping records (A)
The record A specifies IP address for given host. A records are used for conversion of domain names to corresponding IP addresses.
example.com. IN A 18.104.22.168
IP Version 6 Address records (AAAA)
The record AAAA (also quad-A record) specifies IPv6 address for given host. So it works the same way as the A record and the difference is the type of IP address.
linux aaaa 3ffe:1900:4545:2:02d0:09ff:fef7:6d2c
Canonical Name records (CNAME)
A CNAME record or canonical name record makes one domain name an alias of another. The aliased domain gets all the subdomains and DNS records of the original.
mail 14400 IN CNAME domain.com.
www 14400 IN CNAME domain.com.
Mail exchanger record (MX)
The MX record shows that all emails @ mydomain.com should be routed to the mail server at mydomain.com. The DNS record shows that mydomain.com is located at 22.214.171.124. This means that email meant for [email protected] will be routed to the email server at 126.96.36.199. This finishes the task of the MX record. The email server on that server then takes over, collects the email and then proceeds to distribute it to the user “test”.
mydomain.com. 14400 IN MX 0 mydomain.com.
Name Server records (NS)
An NS record or name server record maps a domain name to a list of DNS servers authoritative for that domain. Delegations depend on NS records.
NS Record Name Server Record which indicates the Authoritative Name Servers for a particular Domain. It should be need atleast two nameservers.
example.com. IN NS ns1.nameserver.com.
example.com. IN NS ns2.nameserver.com.
Reverse-lookup Pointer records (PTR)
As opposed to forward DNS resolution (A and AAAA DNS records), the PTR record is used to look up domain names based on an IP address.
Start of Authority records (SOA)
The record specifies core information about a DNS zone, including the primary name server, the email of the domain administrator, the domain serial number, and several timers relating to refreshing the zone.
Text records (TXT)
The TXT records are custom records which contain machine-readable data. The record is used by Sender Policy Framework (SPF) to prevent fake emails to appear to be sent by you.
Example Zone File Format
$TTL 14400 yourdomain.com. 86400 IN SOA ns1.yourdomain.com. youremail.gmail.com. ( 2013060702 ;Serial Number 86400 ;refresh 7200 ;retry 3600000 ;expire 600 ; minimum in seconds ) yourdomain.com. 86400 IN NS ns1.yourdomain.com. yourdomain.com. 86400 IN NS ns2.yourdomain.com. yourdomain.com. 14400 IN A 188.8.131.52 localhost 14400 IN A 127.0.0.1 yourdomain.com. 14400 IN MX 0 yourdomain.com. mail 14400 IN CNAME yourdomain.com. www 14400 IN CNAME yourdomain.com. ftp 14400 IN A 184.108.40.206 yourdomain.com. IN TXT "v=spf1 ip4:220.127.116.11 +a +mx +ip4:18.104.22.168 ?all"
TTL – 14400 – TTL defines the duration in seconds that the record may be cached by client side programs. If it is set as 0, it indicates that the record should not be cached. The range is defined to be between 0 to 2147483647 (close to 68 years !) .
Class – IN – The class shows the type of record. IN equates to Internet. Other options are all historic. So as long as your DNS is on the Internet or Intranet, you must use IN.
Nameserver – ns1.yourdomain.com. – The nameserver is the server which holds the zone files. It can be either an external server in which case, the entire domain name must be specified followed by a dot.
Email address – youremail.gmail.com. – This is the email of the domain name administrator. Now, this is really confusing, because people expect an @ to be in an email address. However in this case, email is sent to [email protected], but written as youremail.gmail.com . And yes, remember to put the dot behind the domain name.
Serial number – 2013060702 – This is a sort of a revision numbering system to show the changes made to the DNS Zone. This number has to increment , whenever any change is made to the Zone file. The standard convention is to use the date of update YYYYMMDDnn, where nn is a revision number in case more than one updates are done in a day. So if the first update done today would be 2005301200 and second update would be 2005301201.
Refresh – 86000 – This is time(in seconds) when the slave DNS server will refresh from the master. This value represents how often a secondary will poll the primary server to see if the serial number for the zone has increased (so it knows to request a new copy of the data for the zone). It can be written as “23h88M” indicating 23 hours and 88 minutes. If you have a regular Internet server, you can keep it between 6 to 24 hours.
Retry – 7200 – Now assume that a slave tried to contact the master server and failed to contact it because it was down. The Retry value (time in seconds) will tell it when to get back. This value is not very important and can be a fraction of the refresh value.
Expiry – 3600000 – This is the time (in seconds) that a slave server will keep a cached zone file as valid, if it can’t contact the primary server. If this value were set to say 2 weeks ( in seconds), what it means is that a slave would still be able to give out domain information from its cached zone file for 2 weeks, without anyone knowing the difference. The recommended value is between 2 to 4 weeks.
Minimum – 600 – This is the default time(in seconds) that the slave servers should cache the Zone file. This is the most important time field in the SOA Record. If your DNS information keeps changing, keep it down to a day or less. Otherwise if your DNS record doesn’t change regularly, step it up between 1 to 5 days. The benefit of keeping this value high, is that your website speeds increase drastically as a result of reduced lookups. Caching servers around the globe would cache your records and this improves site performance.