How domain name works

It has been about 5 years since I bought my first domain name to set up my old WordPress blog. Over the years, I’ve bought several domains and set up some common services with my domains (e.g. website, email). I understand how hard it is to understand the concepts related to domain name when you don’t have much network knowledge. Therefore, I would like to explain some of the important concepts related to setting up your own domain names in an easy-to-understand way.

The scenario

Image that you have bought a domain in order to set up your own blog. And that you know you need some kind of server to host your website, so you bought a web hosting service as well. However, you don’t know how to link your domain to your hosting service so that when someone types your domain name in his/her browser, it goes to your blog. The following section explains the concept you need to know to do that.

The concept

Before we get into details, let’s first think about why we have domain names. Well, the idea of having domain names is pretty much the same as having names for buildings. Although each building in your city has an address, the address is usually hard for people to remember. For example, the address for Google Singapore office is

70 Pasir Panjang Road, #03-71
Mapletree Business City
Singapore 117371

You may not remember this address at all. However, you know the name of the building (i.e. Google Singapore office). You use a search engine to search Google Singapore office, and you get the exact address. In this process, the search engine helps you translate a name into the actual address of a building. This is how it works in the real world. For the Internet, DNS plays the role the search engine plays in the above analogy.

DNS

DNS stands for Domain Name System. It is a system that resolves domain names (e.g. example.com) to IP addresses (e.g. 1.2.3.4). When you own a domain, you need to configure the DNS for that domain. The system basically says what the response should be when a certain type of query comes in. These “question-answer pairs” are what is called DNS records.

DNS record

For each DNS record, it specifies the type of query and the response. There are 2 important query types, namely NS and A.

NS record

NS stands for Name Server. In order to know how to resolve a domain, we first need to know where we could find that information. This is why NS record(s) is useful. Suppose you use CloudFlare to configure your DNS, you should set the NS record to CloudFlare’s server. The NS record(s) can be configured from your domain registrar.

A record

A record, which stands for Address record, is the actual record that maps a domain (or subdomain) to an IP address. If you want to point example.com to the IP 1.2.3.4, then you add an A record for that. This creates an A record for the top level domain. If you want to set up an A record for just test.example.com, you can also do that. This can be helpful when you want to use your domain for multiple purposes (e.g. blog.example.com for your blog, and store.example.com for an e-commerce site).

How things fit together

Now that we explained the concept of DNS, let’s see how every piece fits together to resolve your domain. Suppose we have the following settings

DNS record typeDomainResponse
NSN.A.ns1.example.com
A*.example.com1.2.3.4

Now when someone types in example.com (or whatever.example.com), the NS record will be queried. After the NS server (i.e. ns1.example.com) is known, another query will be performed for A record of example.com (or whatever.example.com). This query will return the actual IP address 1.2.3.4, which the browser will use to connect to your web hosting service.

There you have it. Now your domain name is linked to your hosting service. The steps I described above are not meant to be exhaustive. The whole process is far more complicated than this. However, I believe what I described above is sufficient for anyone to get started with their own domains.

References

 
comments powered by Disqus