DNS Records - NS, A, MX, CNAME, SPF
DNSDNS stands for Domain Name System. It is used to point memorable domain name towards the IP address of the server. This allows you to change web hosting without changing your domain name. Each website has a specific IP address, and the DNS records pair that IP address to the domain.
How DNS Works
Domain names are best understood by reading from right to left. The broadest domain classification is on the right, and becomes more specific as you move to the left. For example,
example.com
mail.hello.example.com
Here, the top-level domain, or TLD, is .com. Every term to the left of the TLD is separated by a period. The first-level subdomains with their TLDs (example.com) are referred to as domains. Moving to the left, hello and mail are the second- and third-level subdomains.
Name Servers
Name servers host a domain’s DNS information in a text file called a zone file. They are are also known as Start of Authority (SOA) records. Every domain’s zone file contains the domain administrator’s email address, the name servers, and the DNS records.
DNS Resolution
First, the domain name needs to get translated into your server's IP address. DNS matches human-friendly domain names to computer-friendly IP addresses. This happens in a special text file called a zone file, which lists domains and their corresponding IP addresses.
Types of DNS Records
A DNS zone consists of the following records:
-
NS: It specifies DNS servers for your domain.
-
A: It specifies IP addresses corresponding to your domain and its subdomains.
-
MX: It specifies where the emails for your domain should be delivered.
-
CNAME: It specifies redirects from your domain's subdomains to other domains or subdomains.
-
SPF: Sender Policy Framework is an attempt to control forged e-mail.
1. NS Record
NS (Name Server) records set the nameservers for a domain or subdomain. The primary nameserver records for your domain are set both at your registrar and in your zone file. The nameservers carry the zone file for your domain.
You can also set up different nameservers for any of your subdomains. Subdomain NS records get configured in your primary domain’s zone file.
2. A Record
A record (Address Record) points a domain or subdomain to an IP address. It allows users to type in an easily recognisable domain and still get pointed to the IP address. An A record will point to an IP. This is the core function of DNS. It is different from name server entry. A name server entry will point to some name servers.
You can point different subdomains to different IP addresses.
An AAAA record is just like an A record, but for IPv6 IP addresses instead of an IPv4 one.
3. CNAME Record
CNAME (Canonical Name Record) redirects one domain to another, allowing you to only update one A record each time you make a change. It points to another domain address rather than an IP address. With a CNAME record, DNS lookups use the target domain’s DNS resolution as the alias’s resolution.
4. MX Record
MX (Mail Exchanger Record) record matches the domain name to a list of servers that handle mail for the domain, and tags each server with a priority. The highest priority is 0. The MX mechanism provides the ability to run multiple mail servers for a single domain, and allows administrators to specify an order in which they should be tried.
5. DKIM Record
A DKIM (DomainKeys Identified Mail) record displays the public key for authenticating messages that have been signed with the DKIM protocol. This increases the capability to check mail authenticity. DKIM records are implemented as text records.
6. SPF Record
An SPF (Sender Policy Framework) record lists the designated mail servers for a domain or subdomain. It helps establish the legitimacy of your mail server and reduces the chances of spoofing, which occurs when someone fakes the headers on an email to make it look like it’s coming from your domain, even though it did not.
An SPF record for your domain tells other receiving mail servers which outgoing servers are valid sources of email so they can reject spoofed mail from your domain that has originated from unauthorized servers.
7. PTR Record
A PTR (Pointer) record matches up an IP address to a domain or subdomain, allowing reverse DNS queries to function. It performs the opposite service an A record does, in that it allows you to look up the domain associated with a particular IP address, instead of vice versa.
PTR records are usually set with your hosting provider. They are not part of your domain’s zone file. As a prerequisite for adding a PTR record, you need to create a valid, live A or AAAA record that points the desired domain to that IP.