Modern System Design

Domain Name System and How it works?

5 min read

In this article, we will cover what is DNS. How does DNS Works internally and How we can configure a DNS server? Let’s get started.

Previously, we have covered below topics:

Modern System Design – Abstraction 

Modern System Design – Non-functional System Characteristics

Building Blocks for Modern System Design

 

 

The domain name system (DNS) is the Internet’s naming service that maps human-friendly domain names to machine-readable IP addresses.

 

The service of DNS is transparent to users. When a user enters a domain name in the browser, the browser has to translate the domain name to IP address by asking the DNS infrastructure. Once the desired IP address is obtained, the user’s request is forwarded to the destination web server.

 

 

Few important definitions:

 

Root Domain:

Root Domain is the highest hierarchical level of a site and is separated from the Top Level Domain by a dot.  Such as example.microsoft.com.

 

Top Root Domain:

A name used to indicate a country/region or the type of organization using a name. eg: .com represent commercial use on a internet.

 

Second level domain:

Variable length name register to an individual or organization for use on the internet. Eg: microsoft.com

 

Sub Domain:

Additional names that an organization can create that are derived from registered second level domain name. eg: Example.microsoft.com

 

Host or Resource name:

Names that represent a leaf in DNS Tree of name and identify a specific resources.eg: a.example.microsoft.com

 

 

Records in DNS servers:

 

  • A records – points to IPv4 address of machine where website is hosted
  • AAAA records – points to IPv6 address of machine where website is hosted
  • MX – points to email servers. Mail Exchanger
  • CNAME – canonical name for alias points hostname to hostname
  • ANAME – Auto resolved alias, works like cname but points hostname to IP of hostname
  • NS – nameservers for subdomains
  • PTR – IP address to hostname
  • SOA  – containing administrative information about the DNS zone. (Start of Authority)
  • SRV – service record for other services
  • TXT – Text records mostly used for verification, SPF, DKIM, DMARC and more
  • CAA – certificate authority record for SSL/TLS certificate

 

 

How DNS Works:

 

Request Information:

The process begins when you ask your computer to resolve a hostname such as www.dns.com.

The first place your computer will look its in the local cache. If the requested IP address is not there. It will look for a domain name system server in the local area network(LAN).

When the local DNS receives the query and the requested domain name is found it will return the result.

If the information is not stored locally, your computer forwards the query to your Internet service provider (ISPs) recursive DNS Server.

 

Ask your recursive DNS Server:

 

Recursive DNS server has their own cache and stores the DNS records temporarily.

Recursive DNS servers also called not authoritative DNS Servers as they provide the resolution based in a cached value acquired from authoritative DNS Servers.

If the recursive DNS server doesn’t have the answer, they query the root nameservers.

 

Ask the root nameservers:

A nameserver doesn’t know the answers but they will direct your query to the right name server that knows the answer. So it will forward the query to Top level domain nameservers.

There are 13 sets of root nameservers.

 

Ask the Top level domain nameserver:

 

The root namespaces will look at the first part of your request, reading from right to left. And direct your query to the TLD nameserver for .com

 

Ask the Authoritative root name Servers:

Authoritative name servers or servers are responsible for knowing everything about domains which includes IP addresses.

So, when the authoritative name server receives a query from the resolver, the name server will respond with the IP address for google.com. And finally, the resolver will tell your computer’s IP address for google.com and then your computer can now retrieve the google web page. It is important to note that once the resolver receives IP address, it will store it in its cache memory in case it receives another query for google.com. So it does not have to go through all those steps again.

 

 

Forward lookup:

Resolve hostname to IP Adress

Reverse lookup:

Resolve IP address to hostname

Zone:

Subtree of DNS Datanase

DNS Client:

/etc/resolve.conf – DNS Configuration file.

Basic testing of DNS resolution:

NSLOOKUP – Is an interactive resolver that allows the user to communicate directly with DNS servers.

 

Types of DNS Servers:

 

  1. Primary Server:

The primary server is the authoritative server for the zone. All administrative tasks associated with the zone (such as creating subdomains within the zone, or other similar administrative tasks) must be performed on the primary server. In addition, any changes associated with the zone or any modifications or additions to RRs in the zone files must be made on the primary server. For any given zone, there is one primary server, except when you integrate Active Directory services and Microsoft DNS Server.

 

  1. Secondary Servers:

Secondary servers are backup DNS Servers. Secondary servers receive all of their zone files from the primary server zone files in a zone transfer. Multiple secondary servers can exist for any given zone — as many as necessary to provide load balancingfault tolerance, and traffic reduction. Additionally, any given DNS Server can be a secondary server for multiple zones.

 

  1. Caching Servers:

Caching servers, also known as caching-only servers, perform as their name suggests; they provide only cached-query service for DNS responses. Rather than maintaining zone files like other secondary servers do, caching DNS Servers perform queries, cache the answers, and return the results to the querying client. The primary difference between caching servers and other secondary servers is that other secondary servers maintain zone files (and do zone transfers when appropriate, thereby generating network traffic associated with the transfer), caching servers do not.

 

How to install DNS servers:

 

  1. Use the below command in linux to install the DNS Server:

Yum -y install bind

  1. Get bind started

Chkconfig named on

To start stop or restart bind after booting use:

/etc/init.d/named start

/etc/init.d/named stop

/etc/init.d/named restart

DNS Configuration file: /etc/named.conf (Serverside)

It tells the BIND where to find the configuration or zone files for each domain you own.

 

This file usually has two zone files:

Forward zone

Backward zone

 

Forward Zone file:

 

Zone “shreyashnaithani.in” {

Type master

Allow-query {any;}

File “shreyashnaithani.in.zone”;}

Backward zone file:

 

Zone “192.168.11.in-addr.arpa” IN {

Type master;

Allow-query {any;}

File “shreyashnaithani.in.zone”;}

 

 

Frequently ask Q&A:

  1. On which version of the bind you have worked?

BIND 9

  1. The port on which DNS work?

Port no 53

  • UDP for query and response
  • TCS for zone transfer
  1. TTL Explain?

Time to live, 32-bit no. indicating the time to live for any record.

 

Thank you for reading. We hope this gives you a good understanding. Explore our Technology News blogs for more news related to the Technology front. AdvanceDataScience.Com has the latest in what matters in technology daily.

Tagged , , , , , , , ,