top of page
Writer's pictureNOURA ALSHAREEF

HOW DNS Works?

Hello readers of the NoraTech blog!


I wanted to share a recent experience I had that made me realize the importance of having a DNS server. Let me explain why it became necessary and how it can benefit all of us.


You see, when we access websites or online services, we usually use easy-to-remember domain names like "google.com" instead of typing in complicated IP addresses. It's much simpler to remember and type a name like "google.com" rather than a string of numbers. I'm sure you can relate!


However, in my particular environment, things were a bit different. Each service in my setup communicated with others using their IP addresses. While this worked fine for a long time, things got complicated when we made changes to our network and moved services to different subnets. I found myself having to manually update the configurations of each service one by one, which was time-consuming and prone to errors. That's when I realized the value of having my own DNS resolver server.


By setting up my own DNS server, I could centralize the management of IP addresses for all the services. Instead of updating each service individually, I could simply make the changes in one place.


Now, let's talk about how DNS actually works.


Understanding The DNS Name Resolution Process

Here's what occurs when you enter a web address [ www.noratech.blog ] in your web browser:


  1. The web browser will first use the DNS protocol to contact the DNS server that has been configured for that device.

  2. The DNS server will respond to the resolution request with the IP address of the website or return a not found message.

  3. Once the browser has the IP address of the website it can connect to it. If the DNS process fails you get a server not found displayed in the browser.


Since I was responsible for building my own DNS server, it was crucial for me to grasp its concepts and logic.

This article provides the essential information, so let's delve into it.


Now, in the scenario mentioned above, the DNS server can respond in two possible ways:

The DNS server confidently declares : "I have the answer! The IP address for www.noratech.blog is 34.149.87.45."

Or

The DNS server takes a moment to check with other DNS servers and then exclaims, "Give me a moment to check with other DNS servers. Ah, there it is! The IP address for www.noratech.blog is 34.149.87.45."

But why does this happen? It's because a single DNS server does not possess knowledge about all the DNS records of every website. It requires additional resources to resolve certain DNS requests.


So, who does it address first? The DNS server needs to reach out to a root resolver because it will provide guidance on where to go next and direct it to the appropriate source.


Typically, the root resolver redirects the DNS server to the TLD (Top-Level Domain) DNS server, which further redirects it to the relevant DNS server. This constitutes the entire process.


Now, let's explore what occurs when you enter the web address www.noratech.blog in your web browser:

  1. You open a web browser and enter www.noratech.blog in the address bar.

  2. The request is sent to a DNS resolver, which is usually managed by your Internet service provider (ISP) or network.

  3. The DNS resolver forwards the request to a root resolver.

  4. The root resolver redirects the request to a TLD (Top-Level Domain) DNS server.

  5. The TLD DNS server further redirects the request to the relevant DNS server.

  6. The DNS server responsible for www.noratech.blog looks up its records and retrieves the IP address, which is 34.149.87.45.

  7. The DNS resolver receives the IP address from the DNS server.

  8. The web browser can now connect to www.noratech.blog using the obtained IP address.

  9. The web server at that IP address returns the requested web page, which is then displayed in the web browser.



To observe the DNS query and identify the resolver DNS, utilize the following command:

The output in my case was:


The DNS response consists of various sections, but the most crucial ones are the Question and Answer sections. In the Question section, it specifies that the query is seeking an A (IPv4 address) record for the domain www.noratech.blog.


The Answer section marks the beginning of the section that provides the DNS records in response to the query.


The line "SERVER: 8.8.8.8#53(8.8.8.8)" indicates the DNS server that was utilized for the query, namely 8.8.8.8.

DNS record types


DNS provides support for a wide range of record types, and the response from the previous dig command showcased a few of them, such as the CNAME record and A record.

However, there are several other types allowing different types of information to be associated with a domain name.


The table below highlights six of the most frequently used DNS record types associated with a domain name:

Record Type

Description

A

Maps a domain name to an IPv4 address.

AAAA

Maps a domain name to an IPv6 address.

CNAME

Creates an alias for a domain name, redirecting queries to another domain.

MX

Specifies the mail exchange servers responsible for accepting incoming email for a domain.

TXT

Stores arbitrary text data associated with a domain, commonly used for domain verification and SPF records.

NS

Identifies the authoritative DNS servers for a domain.

Let's revisit the dig command and narrow down the output to just the answer section with only four lines using the | grep -A 4 command.


In the image below, it shows that both "www.noratech.blog" and "cdn1.wixdns.net" are CNAMEs, indicating that they are aliases pointing to the same A record, "td-ccm-neg-87-45.wixdns.net". This A record is associated with the IP address "34.149.87.45", indicating that all its aliases are also mapped to the same IP.

Thank you for reading this article! I hope you found it informative and enjoyable

In the next article, we will dive into the process of setting up your own DNS server. Before moving forward, make sure you have a clear understanding of the concepts covered in this article.


Stay tuned for more valuable insights into the world of DNS!

33 views0 comments

Comments


bottom of page