# DNS Records

How does a browser knows where did the website lives ?

So giving answer to this question there is a only protocol named as DNS(Domain Name System) where the web browser able to where the website lives behind the scene its a huge process which takes over milisecond to execute. we can’t even imagine such a massive work is going to just know that where the website lives.

DNS which acts as a internets phonebook to translate the human readable languauge into the machine understandable language which is called as IP address a numerical number that’s set. SO lets understand how the actual work happen’s.

* Here what happens when we type a any url on browser it first checks its own internal cache and checks wheather it has recently visited a website and if not browser asks your operating system to check were it checks its own cache and if it not found locally it sends a request to DNS resolver ,here this resolver is for finding websites IP so it acts as a middle-man.
    
* The resolver travel through a hierarchical system of server to find a IP address. Resolver queries a root server and this server directs towards the TLD(top level domain eg. .com). TLD server looks at the domain and directs resolver towards the authoratative name server which is a final step where it finds a IP (A record) and return it resolver. That’s how the browser come to know where the live or it get connects to it.
    

So its been very complicated process which goes on but understanding it is bit easy. So let’s just say DNS is a backbone of a internet.

## **Why DNS record is needed**

Let’s just understand first what is DNS record. DNS records is nothing but the instructions that live in authoratative DNS servers and what the IP address is associated with that domain and how to handle the request for that domain.

why they are needed? Reason is that it acts like internets phonebook translating the human readable language into a machine readable IP addresses, directing web traffic, routing emails and enabling various internet services by providing some of the instructions. hence, keeping it simple DNS records are fundamental instructions that allow internet to work smoothly.

## What an NS record is

NS stands for name server. Name server is nothing but the type of DNS server. It is a server which stores all DNS records, including A, MX records, CNX records (which we are going to study further).

Basically, NS records tell the internet where to go to find out domain’s IP address. It solves one of the problem is that it identifies which DNS servers are authoratative for that domain effectively directing the internet traffic to correct direction to find IP address.

## What an A record is

‘A‘ stands for ‘address‘. It indicates IP address of a domain. If we pull DNS record of any Domain it gives A record which is IP address. It helps in IP address lookups matching a domain name to IPv4 address this helps users device to connect with and load a website.

## What an AAAA record is

DNS AAAA records match a domain name to the IPv6 address. DNS AAAA records are excatly like a A records instead of they store a domain’s IPv6 address instead of it’s IPv4 address. IPv6 is a latest version of internet protocol. Main difference between the IPv6 and IPv4 is that IPv6 are more longer than IPv4 address. IPv6 offers exponentially more permuattions and thus far more IP addresses.

## What a CName record is

‘C’ stands for canonical name. Cname record does not provide a IP address it provides a another domain name. for example a domain name bar.example.com gives a foo.exmaple .com here canonical name must always be another domain name . This becomes useful when multiple services are running on a single server which shares same IP address the services can be website or a FTP server. In this case we can have a cname record ftp.example.com and www.example.com which have its IP address points to main server so in future IP address changes we only have to change A record.

## What an MX record is

‘MX‘ records stands for mail exchange record it directs email to mail server.

So lets learn how it actually works. Message transfer agent is responsible for quering MX records. When a user sends a mail, MTA sends a DNS query to identify the mail servers for the emial recipients. The MTA establishes a SMTP(simple mail transfer protocol) connection with those mail servers starting with priotized domains.
