The Domain Name System is a distributed database located on different servers that stores mapping information between domain names and IP addresses. DNS performs the translation of a domain name to an IP address and vice versa.
Some concepts in DNS
Domain name space
Is a tree structure containing the entire domain space as the following image.
Is a branch of the domain name space. The following is an example of the domain
Each node in the tree has a label. A domain name of any node in the tree is the order of labels in the path from that node to the root, each node's name is separated by a dot
Information about domain names is stored in resource records. Each resource record specifies information about a particular object. The DNS server uses these records to answer DNS queries. Here are a few common resource records:
Top level domain
The domain at the top level just below the root domain in the DNS hierarchy. Top level domains are divided into two main categories:
Some examples of gTLDs:
Some examples of ccTLD:
Image of the DNS tree structure:
Delegation và Authority
One of the main goals of DNS system design is to decentralize governance. It is achieved through delegation.
The authority that administers the domain is called the Authority. The authority governing root domains and gTLDs belongs to ICANN - Internet Corporation for Assigned Names and Numbers. ccTLD domains are governed by countries.
A domain management organization can divide it into sub-domains. Each sub-domain can delegate administration to other organizations. For example, the domain "standford.edu" is administratively delegated to Standard University.
Name server and zone
Name server: A server that stores resource records about the domain and name server information of its sub-domains. Name servers usually only contain complete information about a part of the domain name space called the zone.
Note: The root name server is the name server of the root domain or the root name server of the entire DNS system.
The following is an example of an edu domain divided into zones such as zone berkeley.edu, zone purdue.edu and zone nwu.edu zone. And edu itself is also a zone.
The client side of DNS is called DNS Resolver. DNS Resolver is responsible for performing DNS queries.
There are 3 types of DNS queries:
Following are the steps when performing domain name resolution such as
A few tips when using DNS
Configure local DNS using hosts file
I have a situation where the customer will migrate to a new server without stopping the service on the old server and due to some security rules, the customer configures 2 servers with the following information:
So how to access the website example.com of server B?
I added the following config to the hosts file with the path /etc/hosts on linux or mac machines.
Note: The host file is used as a resource record to resolve domain names to IP addresses.
Then if you type example.com into the browser, it will run to server B's example.com website instead of server A. To confirm if the config is working properly, turn on the browser's Developer Tools and then check the request's Headers information. has the following form:
Request URL: http://example.com/ Request Method: GET Status Code: 200 OK Remote Address: SERVER_ADDRESS Referrer Policy: no-referrer-when-downgrade
Configure DNS for domain name
For a website to work, we must perform the operation of pointing the domain name to that website. And there are two ways to do this:
After the configuration is complete, you can use the following tool to check the domain name configuration information:
Using CNAME records
Suppose you have 2 websites example.com and example.vn on the same server. Then you can configure 2 domain names pointing to the same IP address, but if you intend to change the server's IP address, you must reconfigure the IP for both domain names.
However, if you use a CNAME record, for example, point domain name example.vn to domain name example.com as in the example below, then you need to configure IP only at domain main example.com.
NAME TYPE VALUE --------------------------------------- example.vn. CNAME example.com. example.com. A 192.0.2.23