DEV Community

Cover image for DNS-Domain Name System/Server
Gokul Kannan
Gokul Kannan

Posted on Edited on

DNS-Domain Name System/Server

Lets say, in your browser you are typing a web app name, may be "www.youtube.com" And now this gets resolved as an IP.

"www.youtube.com" => Browser => IP Resolved

Now the query is, When we give that domain name, How does it finds the IP address and goes to that?

What's the architecture behind this?

It looks like a mapping. But there are billions of websites are there. Then who is maintaining all these? If you think all these maintained in a database, then who is owning that DB?

In General, We say it as DNS but how it is getting Resolved.

Now lets see the flow in detail.

Once the user types the domain name in the browser, first it searches in the LOCAL CACHE.

This LOCAL Cache, means it can either reside in your laptop or in your router.

Lets assume we didn't get it from local cache. Now it goes to its parent which is an ISP provider (Jio or airtel etc.,)

Wait but how your router correctly goes to the ISP provider. It is by using parent IP 0.0.0.0 which gets mapped to its parent.

Now in ISP, it receives the Domain Name, there it dissects the Domain Name.

If it has to dissect the Domain Name, there must be something with that Domain Name right?

Let's say if you type "youtube.com." Here it takes us to

The Last "." is the Root or Root Server

Then the ".com" is called the TOP LEVEL DOMAIN (TLD)

Then the next "youtube" is called SECONDARY LEVEL DOMAIN (SLD)

And whatever comes after that is called as subdomains for example: "music.youtube.com"

Here "music" is a subdomain. We can have still many more "." after that, all those will be subdomains.

How we should see this is, we will be moving root to root or point to point

Now lets go back to that ISP. So the ISP receives the Domain.
First it takes the root and asks the Root Server.

This Root Server is maintained by around 7 companies in the world. When we say server, its not like an actual server, its called as Name Server. We will discuss more about this later. Now consider that just like server, which gives us a response based on our request.

So, if the Root Server doesn't know about this entire "youtube.com", but it would know where the ".com" resides means it gives the location of the TLD SERVER (He is the ".com").

Now again we would ask this TLD Server.

So, every webapplication is maintained by the AUTHORITATIVE SEVER which is owned by who owns the application.
Now this TLD server redirects it to that authoritative server of "youtube.com" which maintains all the subdomains.

And remember, the cache will be maintained at each levels. SO, next time it doesn't need to go through the flow again.

All these flow called as IP Resolve process.

Combining all these called Domain Name System.

All these Domain Name Services - TLD and Root servers are maintained by https://www.iana.org/ there are 8 companies under them.

For example standards/protocols like http are standardised by https://www.ietf.org/

What is Name Server?

It is not like any application. But does an important thing which is holding the Zone data.

What does zone data means? Its like a Database of DNS records.
and piece of software to answer the queries.

Now lets see what's inside this zone data and other items

  1. Zone File

Each domain will have a zone file. In that we will have different records like A records, CNAME records, NS records etc.,

Lets see about the records:

  1. SOA Records - Zone Metadata - Server's serial Number refresh periods all such metadata.

  2. NS - Name Server - which servers are authoritative for the Zone.

  3. A/AAAA - IPV4 is given for A and IPV6 for AAAA

  4. CNAME - is creating an Alias. Lets say instead of "youtube.com" I can set it like ""youtube.gk.com" also goes to "youtube.com". Even subdomains can be added CNAME.

So a subdomain can be mapped to a CNAME or with A record (which means giving IP)

Mapping subdomain with A record (you can see it asks for IP) :

Mapping subdomain with CNAME record (here just asks for name and Alias of) :

Other Records,

  1. MX - Mail Servers - To manage mailids.

  2. TXT - Metadata verification - Domain Verification.

All these records stays inside a Zone data. This file is hosted by a Name Server or Domain Name Server.

These name servers are maintained by different services. For example if you get a domain from the wordpress, your DNS is maintained by wordpress.

How can I maintain this Name server into my machine, that is possible using the Route 53, where you can create a hosted zone and there it could give you Name Servers which can be used to route traffic to your domain by that you can control that as a authoritative server.

Also the main purpose of using a DOMAIN Name is that it just acts as a Label to reach your server, behind that you can change your IPs for your convenience, but for the end user, the Domain name stays the same.

Also additional info: either you can give A or AAAA record for a domain, not both.

Normally the domain names gets resolved using the Root servers - 8.8.8.8 which maintained by google (this is by default). And there are other DNS/Root servers like maintained by cloudflare, 1.1.1.1

Top comments (1)

Collapse
 
m_montazeri profile image
Mohammad Montazeri •

Two corrections would make the resolver flow clearer. A hostname can publish both A (IPv4) and AAAA (IPv6) records; these are separate record types, not mutually exclusive alternatives. RFC 3596 adds AAAA while retaining existing IPv4 support: rfc-editor.org/info/rfc3596/

Also, Google Public DNS is a recursive resolver, not a root name server. Google’s own overview explicitly distinguishes it from an authoritative name service: developers.google.com/speed/public...

Showing the recursive resolver separately from root, TLD and authoritative servers would help readers follow the lookup. AI-assisted reply; I work on Lisar Connect.