DNS Record Types Explained
Whenever you type www.google.com in the searchbox of your browser it doesn’t understand what google.com means.Yes,your browser doesn’t understand what we write in english or anyother language,it only understand IP addresses like 192.1.1.1.That’s why DNS is needed because it converts the human-freindly content in machine-readable format.
What DNS is (explained in very simple terms)
DNS means Domain Name System. It is also called the phonebook of the internet.It acts as a translator that converts human-freindly names into machine-readble IP addresses.for example - If you want to call your freind “xyz”.You don’t remember their phone number.you just look up at thier name in your phone’s contact list.and then you click on that name and the phone dials it for you.DNS does the exact same thing for websites.
Whenever you type google.com or something else in your browser the DNS search the IP address.Once it finds it,it tells your browser and your website open instantly.
Without DNS, it is impossible for us to remember a long confusing string of numbers for every website we visit.That’s why DNS is so important for us.
Why DNS records are needed
DNS records are instruction that lived in authorative DNS server and they needed us because they tell us the information about our domain such as:
Where the website is located
To deliver emails
Who manages the domain
To find the nicknames(CNAME) of websites
Now Let us understand some of the important records one by one.
NS Record :-
NS stands for ‘nameserver‘ and it tells the browser that which DNS server are authoritative for our domain.In Simple words,it tells the browser that who is the incharge of this domain.
In today’s world most websites use more than one nameserver so that if one nameserver goes down,the another one can answer the queries of DNS.This makes the websites more reliable.
Simple Example:
example.com → ns1.cloudflare.com
example.com → ns2.cloudflare.com
What this means:
“That if you want any information about example.com then ask these servers.”
A Record :-
The “A“ stands for “address“ and this is the most fundamental type of DNS record.
It indicates the IP address of a given domain.
Simple Example:
example.com → 93.184.216.34
What this means:
“If you want the DNS record of “example.com” then A record return you the IP address “93.184.216.34”.
In simple words, an A record connects a domain to an IP address and the most important thing is that an A record only holds IPv4 address only.
AAAA Record :-
DNS AAAA records match a domain name to an IPv6 address.DNS AAAA records are exactly same like A record,the only difference is that they store a domain’s IPv6 address instead of IPv4 address.
In Simple words,the AAAA record connects a domain name to an IPv6 address and it uses 128 bit IPv6 address instead of 32 but IPv4 address.A record and AAAA record both are same but their fomats are different.
Simple Example:
example.com → 2606:2800:220:1:248:1893:25c8:1946
What this means:
“When you asks DNS for eample.dom then AAAA records returns you an IPv6 address.”
CNAME Record :-
The CNAME stands for "canonical name".A CNAME record points from an alias domain to a “canonical” domain.In simple words, CNAME record makes one domain name points to another domain name.It is just like a nickname that points to the real domain name.
All CNAME records must points to a domain,never to an IP address.
Simple Example:
www.example.com → example.com
What this means:
“When you type “www.example.com“ then DNS sees that this is not a real address.It’s just an another name for example.com.Then DNS goes and check example.com instead of this and when it finds the A/AAAA record of example.com,the website opens.”
MX Record :-
MX stands for “mail exchange”.A DNS mail exchange record directs email to a mail server.
The MX record indicates how email messages should be routed in accordance with the SMTP(Simple Mail Transfer Protocol).
In simple words,MX record tells the internet where to send emails for a domain.MX records does’nt send emails or store emails,they only provide the address where to deliver emails.
Simple Example:
@example.com
What this means:
“When someone sends an email to user@example.com then mail server asks DNS where should i deliver mail for example.com then DNS replies with MX record and says deliver this mail to “mail@google.com”. It deliver to google.com because the domain owner told DNS to use google for emails.
user@example.com → mail@google.com
TXT Record :-
The DNS TXT record lets a domain administrator enter text into Domain Name System.
In simple words, a TXT record stores plain text information in DNS.It is just like a sticky note that you attach to your domain name.The Text is stored in the form of one or more strings within quotation marks. and only the owner of the domain could add these texts.
Simple Example:
example.com → "hello chai aur code"
What this means:
“That DNS is storing some text for the domain”
How all DNS records work together for one website
When someone types www.example.com,then DNS first checks who manages the domain using NS records.Once the correct nameservers are known then sees that www.example.com is just a nickname that uses CNAME record ,and it is redirected to example.com the original domain.DNS then uses A or AAAA record to find the real IP address of the server so the website can open.and then when someone sends email to user@example.com then DNS uses the MX record to decide which mail server should receive the email such as google,yahhoo or any other provider.and then the TXT record is used to verify the domain and make sure that emails are real not fake.Together all these DNS records tells the inernet that where the website lives,where email should go,and services like security and load balancing function seamlessly.