Web Development Core Concepts - Domain Name System (DNS)


Welcome back to web technology core concepts at Learning Journal. In the earlier videos, we accomplished the first part of giving a search engine friendly URL to our website. The next thing that we want to do is to replace this IP address with a meaningful domain name. Well, that's an easy thing to do, but before that let's find a good name for our website. What name do you want to give?

Domain Name Registration

Whatever name you arrive at, it must be a unique name across the Internet.
No one else should be using that name for their website. That's a complex requirement, and hence there is a commercial part of the domain names.
If you want to give a unique domain name to your website, you need to follow these steps.

  1. Search for domain name availability, I mean, nobody should have already taken that name.
  2. Pay and register the domain name, that means, no one else can take the domain name after your registration.
  3. And finally, use it for your website.

Let's start with the first thing. Many companies allow you to search for the available domain names. If someone else has not already registered the domain, they offer you to register it in your name.
Let's do that. Let's try searching with the help of GoDaddy domain name search. I want a name as MathMagic. Let me explore that.
Ok, Someone has already taken MathMagic.com.
But what is this? The list of domain name extensions? It shows a bunch of domain name extensions here.
.in, .co, .info, .com, .education and many more.
What are these extensions and what is the purpose of having these extensions? I mean, I wanted a name as MathMagic. Where do this dot com and other extensions come into the picture? Let's try to understand that.

Domain Name System

We already have millions of websites on the internet, and thousands of new sites are being registered every day. Everyone needs a name. Right? And this ever growing requirement to create a unique website causes a bunch of problems. Let's me talk about a couple of those problems.

  1. It is a big problem to give a unique but meaningful name to everyone. There are always more than one parties that would be interested in the same name. For example, I am interested in MathMagic, but someone else has already taken it. What can we do to help this situation?
  2. Think about the list of all domain names that are already registered. There were more than 350 millions of such names by the end of 2017, and that number is still growing. Who will manage such an extensive database and how can we simplify that problem.

These two problems are at the core of the domain name system. How do we solve it? The problem is taken up by the IETF (Internet Engineering Task Force), and they developed a specification and standard for the Domain Name System.
They came up with an excellent idea of a hierarchical decentralized naming system for computers and other services that are connected to the Internet. Let's try to understand that system at a high level.

  1. Every computer or service that is connected to the internet is assigned a unique domain name and an IP address. This mapping along with other necessary information is stored in a dedicated system called a domain name server.
  2. The domain name follows a hierarchical naming separated by a dot symbol. The rightmost part of the domain is a top-level domain or a TLD. Then comes the actual name of your domain. And finally, you may have an optional subdomain name. These three parts are separated by the dot symbol.

That's it. The DNS system is a complicated thing to understand. However, at this stage, the above two statements are more than enough to understand the core concept behind a DNS system.
You might be wondering how this system helps to solve the two problems that we talked about earlier. Let's try to understand that part.

What is a TLD, gTLD, and ccTLD?

The first problem has a simple solution. I wanted a name as MathMagic. However, when I searched for it, I realized that the MathMagic.com is already registered by some other person or company. MathMagic.com is not available, and I can't do anything about it. However, I still have a bunch of other extensions or TLDs. I can try with mathmagic.net, mathmagic.org, mathmagic.edu and so on. If I am looking to register this name with specific relevance to a country, then I can use a country code based TLD. For example, mathmagic.in will make more sense for the Indian audience. Similarly, mathmagic.us makes more sense for the US market.
However, there is an important point to note here.
We have a predefined set of TLDs that is maintained by the ICANN - Internet Corporation for Assigned Names and Numbers. You can choose one of the TLD from that list. You can't come up with your own top-level domain name and use it to register your website name.
Great. One last thing. The TLD s are classified into two groups.

  1. gTLD - Generic Top Level Domain
  2. ccTLD - Country Code Top Level Domain

If you want to reflect your websites for a specific country, you might want to register a domain name with the ccTLD. For example, amazon.com has a country-specific domain for India as Amazon.in.
If you don't want to reflect your website name in a specific country, you should favor a gTLD. The dot-com top-level domain happens to be the oldest and the most popular gTLD. However, you can get a list of all available gTLD at the ICANN website.
The Idea is to pick up a gTLD that makes more sense for your business or the organization.
Great! By adding a TLD to the domain name system, IETF managed to solve the first problem to some extent. The TLD makes it possible for more than one parties to register the same name with different extensions. I can't get matmagic.com, but I can still get mathmagic.fun or mathmagic.school. Right?

Domain Name Server

The next problem with the domain name system is the sheer size of the database. The IETF had the challenge to design a system that can handle an ever-growing volume of the registered domain names. And they addressed this problem by defining a distributed domain name server. What is that?
Let me explain that in two parts.

  1. What is a Domain Name Server or a DNS
  2. What do we mean by the distributed DNS

The domain name server is nothing but a program which holds information about a bunch of domain names. We can send our queries to the DNS, and it responds back with an answer to our query. For example, I can query the DNS for the address www.learningjournal.guru, and it returns an IP address for the host machine. That's it. That what the browser needs to send the request to the web server.
Now let's come to the distributed thing. So the idea is to create multiple domain name servers across the globe and distribute the work among those servers. What does that mean? Let's try to understand that with an example.

How does a domain name system works
Fig.1 - How does a domain name system works?

Let's assume I submit a request for www.learningjournal.guru to my browser. That request goes to the DNS resolver. The DNS resolver is a software service that is managed and offered by your internet service provider. The job of the DNS resolver is to find the IP address for the learningjournal.guru. Now, the DNS resolver sends this request to the nearest DNS root server. There are a bunch of DNS root servers across the globe, and they are operated and managed by various vendors under the guidance of ICANN. The DNS root server doesn't know the IP address for the learningjournal.guru. However, it knows the details of the name server for the .guru TLD. I mean, the DNS root server returns an address for another DNS server that manages the details for the .guru TLD.
Great! The DNS resolver now sends the request to the .guru TLD name server. The .guru TLD might not even know the exact IP for the learningjournal.guru. However, it knows the address of the name server that manages the learning journal name. So let's assume it says, please go to following IP (216.69.185.46). Now the DNS resolver reaches out to the given IP address, and that's the name server that actually knows the IP address for the learningjournal.guru. So it returns the IP address to the DNS resolver. The DNS resolver returns the IP to the browser, and finally, browser reaches out to the web server of the learningjournal.guru.
Great! I hope you understand the Domain Name System. Let me summarize.
The Domain Name System has three major components.


  1. The domain name standard to define a domain name record. This is nothing but the domain name data.
  2. The domain name servers. These are nothing but a software service that is provided by a bunch of vendors under the control of ICANN.
  3. The domain name resolvers. These are also a software service that is offered by your ISP.

When you register a domain, your registrar will create a domain name record in the name server for the TLD. In case of my example, my registrar has built a data record for learning journal in the name server of .guru TLD.
My domain name registrar also maintains a DNS that actually stores the IP address of the www.leraningjournal.guru web server, and as an owner of the learning journal dot guru, I have to create that record using my registrar's website.
Great! Let's assume that I already purchased a domain name from godaddy.com. In that case, godaddy.com is my domain registrar, and MathMurga.com is my domain name.

How to configure a domain name for your website
Fig.2 - How to configure a domain name for your website

Since the registration is already complete, my registrar must have already created a record in the .com TLD name server.


I have already purchased the domain name MathMurga.com, and the registration process is already complete. Now all I need to do is to create an address record using my domain name registrar's website. Let's do that.

First thing is to log in to your domain name registrar's website.
Then go to the DNS management console. You will see many records. However, there are two essential records.

  1. A record
  2. CNAME record

The A record is the address record. If you already have an A record, you need to edit that, if you don`t have an A record then add a new A record and fill in the necessary values. The most important value is the IP address of your website. Save it and done.
The next record you must edit is the CNAME record, the name field requires the subdomain name. You are using the most common subdomain www.
That`s it. Save it, wait for 5 minutes and check your website using the domain name.
Great! Domain Name System is doing its work.

Great! In this lesson, we learned about Domain Name System and also learned how to create an address record to attach a domain name to your website. Once all that is complete, you can access your website using your domain name and there is no need to remember IP address.
A typical website will have a home page. The Homepage is the default page that opens when you type the domain name for the website.
Great! Thank you for watching Learning Journal. Keep learning and keep growing.


You will also like:


Functional Programming

What is Functional Programming and why it is important?

Learning Journal

Pure Functions

What are pure functions and side effects. Start learning functional programming.

Learning Journal

Statements and Expressions

Statements and Expressions in Scala. How are they different?

Learning Journal

Scala named arguments

Learn about named arguments and default values in Scala functions with examples.

Learning Journal

Anonymous Functions

Learn Scala Anonymous Functions with suitable examples.

Learning Journal