Tech WikiFeatured

DNS records Explained : CNAME , NS , A record, MX

Hi Guys, everyone who tries to host their site as simple as WordPress they have to come across terms like DNS (which maximum of you know) , CNAME , A record, etc… & also one needs to update or configure them for the routing. Let’s see each one of them in simple terms (no complicated terminology) what they mean & their functionality.

Simplified Version (visiting this blog ie. : https://byteman.tech ) 
 You type the URL in the browser.
 Browser Uses public DNS (eg : google Domain Name Server ip address is 8.8.8.8) to retrieve nameservers for byteman.tech
 Public Nameservers return two server names ie.  NS1 & NS2 for bitsofjarvis.com
 Browser ask the nameserver (NS1 & NS2) for A(address) record [IP address] for the domain byteman.tech
 Browser sends the request to IP address along with the requesting page.
 Server with the [IP address]  will serve the content the browser requested.
 Browser Caches at different levels to speed up things.
Plaintext

Constraints/Problems for the machine:
Let me discuss why there so many configurations for just simple web hosting. Obviously, humans never want to make things complicated unless it’s required. As a machine below are the constraints
1.) An application/machine cannot take any decision of its own, so we need to tell EACH & EVERYTHING to it in form of configuration.
2.) It only understands 0 & 1. (Any number can be represented in Binary representation)
3.) String or Alphabets is for human readability Only.

Let’s work backward so that it would make some easy sense to you.
Our Aim : To host a simple website showing your picture & name. eg: https://dnsconcept.learning.goodboy/getpic
So whenever, as soon as the above url is entered your picture appears on the browser. SIMPLE !!!!! Let’s discuss what goes behind the scene.
(bonus question: Why cannot we use our local laptop to host any website? Why spend money on hosting? )

Now we have to configure somehow different servers or webservers or machines so that whenever someone in the world types those URL can see your picture & name. Server/Browser doesn’t understand string literals. ONLY NUMBERS.
Every server is given an ID in the internet world so that they can connect/communicate via ID. This ID is called IP address.In layman’s terms, so every server is given a number, this number can be anything like 201, 101, etc… but to cover all the computers of the world we have chosen to give a 32-bit long address. Why 32 bit long? Simple answer: because Vint Cerf decided so. Using a 32-bit address one can name 2^32 servers (4.3 billion).

What is DNS ?


To the browser accessing the url “https://dnsconcept.learning.goodboy/getpic” doesn’t make any sense. He needs IP address of the server where your image file & html content are kept.
Something like “https://12.34.567.89/getpic” makes sense. Web server service like (Nginx , Apache) running on server IP “12.34.567.89” will read the http request made by your browser, will understand it , will route inside the server to the corresponding application running/serving to that URL ie “/getpic“. Then that application will return the HTML file containing your name & the image link.Then browser will display your corresponding picture & name. TADA !!!. Aim achieved.
Now the issue is , who likes to write IP address in the browser & there are millions of website, accessed by millions of users all over the world. To make it easy for us to remember the site name we use string name called a domain name.
Its the same as saving a phone number with a name on your mobile phone. You can dial using the name or directly 10 digit phone number(not everyone remember 10 digit mobile number). Same as it is here. It’s done for our convenience.

As in mobile number is saved locally in your own personal mobile, domain name & their corresponding IP address is saved in DOMAIN NAME SERVERS publicly, so that anyone can refer to get the IP.

What are the nameservers ?



Nameservers contain information regarding the domain location.
eg : Suppose You bought the domain from  Internet Corporation for Assigned Names and Numbers (ICANN) or Domain registrars like Godaddy or NameCheap. Great ! Now you have told the world this domain is bought by you. Now you want to host your wordpress site, for this you went to Amazon EC2 or google cloud.
Google cloud or Amazon EC2 servers have their own IP address where website contents are hosted, this should be known to any browser so they can make request from these IP’s (A record) , these information is kept by nameservers.
(Please do comment if u able to visualize the flow or need little more info. Happy to help you. )

A record
This is the main configuration where we tell from where to fetch the resources or where the website is hosted the actual IP adress of the serving host.

CNAME record:
Canonical name or alias names for the same hosting domain.
Eg : You have multiple sub-domain like dnsconcept.learning.goodboy , cname.learning.goodboy , aname.learning.goodboy.
Above all domain would be pointing to same server IP but by logically different name. So here one can create like three entires of A record
dnsconcept.learning.goodboy : 12.34.567.89
cname.learning.goodboy : 12.34.567.89
aname.learning.goodboy : 12.34.567.89

OR
dnsconcept.learning.goodboy : learning.goodboy
cname.learning.goodboy : learning.goodboy
aname.learning.goodboy : learning.goodboy

What is MX Record?
It tells the IP address of the EMAIL server.

What is TXT Record?
It is kind of open text area for domain owner holder to write anything. Its like a note for your domain you wanna put in.

Leave a Reply

Your email address will not be published. Required fields are marked *