Skip to main content

Command Palette

Search for a command to run...

DNS Record Types Explained

Published
5 min readView as Markdown
S
👋 Hi, I'm Shivani Sodha, a Computer Engineering student passionate about web development and technology. I enjoy building projects with the MERN stack, exploring new technologies, and sharing my learning journey through technical blogs. Currently, I'm focused on strengthening my full-stack development skills, building real-world projects, and continuously learning something new every day.

When you type the website name for example… app.com what do you think should happen?

Because we know that data is delivered using the IP address only so we need to convert this app.com into the IP address.

This thing is done by the DNS.

The main duty of the DNS is to convert or translate domain name to the IP address.

For doing this there are some arechiture of there system that they follows.

First when we type any domain name it checks the cache if it is having already that name then it just simply give the ip adress no need to go and do the dns query.

But if the cache don’t have that domain name the query first goes to the root DNS server.

The root DNS server doesn’t have the IP but it tells to whom we should ask the next

So it send us to the TLD server.

The TLD means top level domain name it manages the domain at the top level such as,

  • .com

  • .org

  • .net

  • .dev

  • .in

It does not have the IP but it tells whom to approach next.

Finally by this we got the authoritative server and this server has the IP.

This DNS servers store critical information about domains.

DNS servers use the information in DNS records to route internet traffic

So based on the different types of the information the DNS server has different types of records.

A record

It gives the IPv4 address of the domain name.

for example:

TYPENAMEVALUE
Aexample.com203.0.113.10

AAA record

It is same as the A record the only difference is that it gives the IPv6 address of the domain.

for example :

TYPENAMEVALUE
AAAexample.com2607:f8b0:4005:805::200e

CNAME record

CNAME records are only required when you connect your own domain to a third-party hosting service.

There is a problem with the A records if we want to connect our own domain with the third-party hosting service then suppose that third party directly provides us A record .

Now in case of some situation in the future if they changed there servers then they have to message every user and the user have to personally change there A record , this thing will take so many time and also if they have so many user then they have to message so many account

To make this thing simpler we use the CNAME record

In this CNAME record the c stands for the canonical name

Means it gives the nickname to our domain

So it basically has the two domains where the 1st domain points to the 2nd domain.

You have to query that 2nd domain name and then you will get the IP.

This IP of the 2nd domain is apply for the 1st domain also.

For example:

  • blog.hashnode.com

  • this blog will point to the Hashnode.com

  • and this hashnode.com will give you the IP

  • Suppose the IP of the hashnode.com is 203.0.113.10

  • Then the IP of your blog is also 203.0.113.10

So now the services will create there own domain name and gives this domain name the IP address now this domain name will be given to their users.

Now if the service change there servers they only change their A record then the IP of all the user changes automatically.

This way the problem created by the A record is solved by the CNAME.

TXT record

TXT record stores the extra information of the data that is important and used for the domain verification or other forms of verification.

In short they are only for instructions, rules, and verification.

It acts like act like written rules or notes attached to a domain.

For example:

NAME:example.com

TYPE:TXT

VALUE: v=spf1 include:_spf.google.com ~all

Meaning:

Only Google’s mail servers are allowed to send emails for this domain.

  • Email servers would not know which servers are allowed to send emails for a domain

  • Fake and spam emails could be sent using your domain name

  • External services could not verify that you actually own the domain

So for solving this type of problems the TXT record is required

MX record

MX stands for mail exchange.

Domain IP address cannot say that where the email will go for the mechanism of the email we need this MX records.

An MX record tells the internet which mail server should RECEIVE emails for a domain.

If we want to recevie the email then only we use the MX record for sending the emails there is no need of the MX records.

It is because when we are sending the emails that time the DNS query happens and based on the reply of the DNS query we send the emails.

understanding it by the example will make it easy.

suppose:

Someone sends email to

user@eample.com

Now the sender’s mail server will ask where to delliever the email.

That time the DNS replies with the MX record.

aspmx.l.finding.com

Then the sender will send the email to mentioned server.

This is the basic task of the MX record.

ex:

example.com. 3600 IN MX 1 aspmx.l.google.com.

Emails sent to @example.com will be received by Google’s mail servers.

NS record

An NS record tells the internet which DNS servers are authoritative for a domain.

So you might thing that so when you type the CNAME or the any other record that time also the NS record is working for you or not?

So the answer is yes that time also the NS record is working behind the scens.

The simple hierarchy is somewhat like this

Domain
  ↓
NS record (who is responsible?)
  ↓
Name Server
  ↓
CNAME / A / MX records (actual answers)

so basically the they tell browsers where to look for IP addresses, MX records, etc.

Complete DNS though the example :

When a user opens blog.shivani.com, the browser first checks the NS (Name Server) records of shivani.com, which point to Cloudflare. This tells the browser that Cloudflare is responsible for managing the DNS of the domain. Cloudflare then looks up the DNS record for blog.shivani.com and finds a CNAME record pointing to hashnode.com. The browser then resolves hashnode.com, which has an A record that maps it to the actual server IP address. Finally, the browser connects to that server IP and the website loads successfully.

shivani.com
   ↓ (NS)
Cloudflare DNS
   ↓
blog.shivani.com → CNAME → hashnode.com
   ↓
hashnode.com → A → Server IP
   ↓
Website loads

More from this blog

Tech Blogs

14 posts