Domain Name System (DNS)

In this tutorial, you will learn the basic concepts of the Domain Name System (DNS). After reading this tutorial, you will know the namespace, domain types, DNS messages, and DNS resolutions.

Contents:

  1. Domain Name System (DNS)
  2. Name Space
  3. Domain Name Space
  4. Name Space Distribution
  5. Types of Domains
  6. DNS Resolution
  7. DNS Messages
  8. Dynamic Domain Name System (DDNS)

Domain Name System (DNS)

Domain Name System is also known as Domain Name Service or Domain Name Server. Every website has an IP address. Every website we access, access through an IP address. It takes a lot of time to remember the IP address of a website. That’s why DNS is introduced. DNS provides URL because it is easier to remember URL name rather than IP.

  • DNS is designed to convert 32-bit numeric IP addresses into simple, easy, and recognizable names.
  • For example, a website has the IP address 78.123.45.111, and DNS changes the IP 78.123.45.111 to the simple domain name abc.com. Now remembering abc.com is easier than remembering the 78.123.45.111 IP address.
  • DNS includes the format for requests, responses, and data.
  • When a user types a website name, the DNS server finds the IP address of that website and displays the result of the query.

Name Space

When DNS converts an IP address to a domain name or URL, the URL must be unique. No two websites have the same URL. Each URL is unique in itself. The namespace maps each address to a unique name and can be arranged in a flat or hierarchical format.

Flat Name Space: The flat namespace contains the name, which consists of a sequence of characters without structure. For example, in abc.com, abc is referred to as a flat namespace.

advertisement
advertisement
  • The main disadvantage of using a flat namespace is that it can be duplicated because the Internet is very large, so it must be controlled centrally.

Hierarchical namespace: In this namespace, the URL is in a hierarchical format, which means that each name is made up of several parts.

  • For example, the website of the two organizations has a blog section. The first organization is given a name by a central authority, company1.com, and the second organization is named company2.com. When these organizations add the name of the blog to the name already given, the result becomes blog.company1.com and blog.company2.com, both of which are different names.
  • Here, the central authority only controls domain names like company1.com and company2.com, not the whole.

Domain Name Space

To have a hierarchical namespace, the domain namespace is used. We can define the name as an inverted tree structure with a root. The tree has a maximum of 128 levels.

The figure below explains the hierarchical tree structure.

hierarchical tree structure
  • As shown in the figure, the root node is zero and has children. Also, each node in the tree has a label, a string containing a maximum of 63 characters.
  • To achieve the uniqueness of domain names, children nodes of the same parent have different labels.
  • Here, the domain name is a sequence of labels, as shown in the figure. For example, blog.networking.company.com. Known as a fully qualified name because a label is terminated by a null string.
  • blog.networking.company.com. defines that it is a blog section of the networking section of the commercial company.
  • A fully qualified domain name (FQDN) contains the full name of the host, from the most specific to the most general.
  • The second is a partially qualified domain name (PQDN), which means that it is not terminated by a null string and does not reach the root. For example, blog is known as a partially qualified domain name because it is not terminated by a null string.

The figure below shows the FQDN and PQDN.

FQDN and PQDN

As shown in the figure, the domain name that ends with a null string is known as FQDN, and the domain name, which does not end with a null string is known as PQDN.

Name Space Distribution

Information related to the domain name space is stored. But there are a lot of domain namespaces in the world and it is very inefficient and unreliable to store such a huge amount of data in one system. At the same time, many users request web access, and responding to the requests puts a heavy load on the system. Therefore the distribution of namespaces is necessary.

Name Servers: The solution to the above problem is to distribute namespace information among multiple servers, known as name servers (DNS).

advertisement
  • DNS allows domains to be divided into smaller domains known as subdomains.
  • As we saw the hierarchy of namespaces, we also have a hierarchy of domain name servers.

Zones: We cannot store the entire hierarchy of domain names on a single server. For that, we have divided the domain name hierarchy into multiple servers. Here, the zone is described as the area covered by the server and the server responsible for it.

  • The DNS server creates a zone file to store information for each node under that domain.
  • If the server doesn’t have a subdomain or it doesn’t divide domains, then the domain and zone are the same.

The diagram below explains the zone and domain.

Zone and Domain

As shown in the figure, the high-level server manages the .com domain, and the low-level server manages the sub-domains of the .com domain.

Root Servers: Root servers located in the zone consist of a complete tree. It keeps references to other servers and assigns rights to them. Normally, the root server does not store any information about the domain. Root servers are distributed around the world and each root server covers the entire domain space.

Primary and Secondary Servers: Primary and secondary servers are types of DNS servers. The primary server is responsible for creating, managing, and updating the zone file to which it is an authority. The secondary server takes information from the primary server and transfers the complete information about a zone.

advertisement
  • The primary server loads all the information from its local disk, and the secondary server receives all the information from the primary server.
  • The secondary server downloads all the information from the primary server, which is known as zone transfer.

Types of Domains

The domain namespace on the network is divided into generic domains, country domains, and inverse domains.

Generic Domain: It defines the behavior of registered hosts. For example, if one wants to open an online business, he can use the .com domain, which defines that the type of business is commercial. Similarly, .org for non-profit organizations, .edu for education, etc.

The diagram below shows the generic domain.

generic domain

As shown in the figure, different domains are used for different purposes. For example, .com, .org, .gov, .edu, and .net are used for commercial organizations, non-profit organizations, government institutions, educational institutions, and network support centers, respectively.

Country Domain: Country domain consists of two characters. They use the abbreviated form of the country name. For example, .in for India, .us for USA, .ca for Canada, etc. The address abc.edu.in means ABC college of India and type educational.

Inverse Domain: Inverse domain is used when mapping an address to a name is required. For example,

the client sends a request to the server but the server has only authorized client IP addresses. Therefore, the server sends a query to the DNS server and asks it to map the client’s address to a name to determine whether the client is authorized.

DNS Resolution

The mapping of names to an IP address is done by the DNS resolution method, this is known as name-address resolution.

  • Whenever a client writes the IP or URL address of the site, the resolver known as the DNS client accepts the query and performs a mapping from the IP address to the name or from the name to the IP address.
  • The DNS client sends the mapping request to the nearest DNS server. If the server has the information, it performs the query operation; otherwise, it refers the resolver to other servers.
  • After receiving the mapping from the DNS server, the resolver also verifies the mapping to check whether it is a real resolution or an error.

Recursive resolution: In this resolution, the DNS client seeks answers from DNS in a recursive manner.

The figure below explains the recursive resolution.

Recursive DNS Resolution
  • As shown in the figure, the DNS client sends a resolution request to the DNS. If the DNS is responsible for that zone and has authority, it checks the database and finds the answer to the query.
  • If the DNS server is not responsible for that zone or does not have authorization, it sends a request to another server and waits for a response to the query.
  • Once the query is resolved, the response is passed back to the requesting client. This process is known as recursive resolution.

Iterative resolution: Another resolution is an iterative resolution, which is used when the customer does not ask for a recurring answer.

The figure below explains the iterative resolution.

iterative resolution
  • As shown in the figure, the client sends a mapping request to the server. Once the DNS server receives a mapping query from the client, it checks whether it can resolve it. If it cannot resolve, it returns the IP address of another server that can resolve the query.
  • If the new DNS server resolves the query, it answers the query with an IP address; otherwise, it also returns the IP address of another server, which can resolve the query.
  • This process continues until the query is resolved by the server. This process is known as iterative resolution.

DNS Messages

Query and response are two types of DNS messages, and both are of the same format. Query and response both contain some information.

The diagram below shows the query and response messages.

query and response messages
  • As shown in the figure, the query message contains headers and question records, and the response message consists of headers, question records, answer records, authoritative records, and additional records.
  • It also shows the header format. Both query and response messages have a header field, where query messages have some fields set to null.
  • Every time the user sends a query, a different identification number is used, and the identification number is used to match the query and response. Flags define the type of message, the type of reply requested, the type of resolution, etc.
  • Question Section: The Question Section is present in both the query and response messages. Basically, Question Section contains one or more question records.
  • Answer section: This defines one or more resource records, including the answers that the DNS client (resolver) receives from the server.
  • Authoritative section: This field defines information about the authoritative server to query.
  • Additional Information Section: This helps the resolver to find the authoritative server, which can resolve its query.

Dynamic Domain Name System (DDNS)

In the past, the Internet did not have many addresses, and DNS was designed based on that information. But nowadays, the internet has so many addresses, and DNS needs so many manual updates. The DNS must be able to detect changes to the Internet such as a new host added, a host removed, or an IP address change, so that it can write to the database. These problems become a headache for network operators, as there are so many manual updates.

  • To solve the above problems, DDNS (Dynamic Domain Name System) was introduced. In this, the file is updated dynamically.
  • When a new host arrives and name and address bindings are determined, the DHCP server notifies a primary DNS server, so the DNS server can update the zone.
  • When the primary server is updated, the secondary server also receives updates either actively or passively.
  • In Active Notification, when the primary server is updated, it sends a message to the secondary server about the change in the zone.
  • In Passive Notification, the secondary server periodically checks for any changes in the zone, and if it detects the changes, it downloads the new file from the primary server.
  • In addition, DDNS also protects against unauthorized access and attacks by using an authentication mechanism, which is not present in DNS.

Key Points to Remember

Here is the list of key points we need to remember about “Domain Name System (DNS)”.

  • DNS is designed to convert 32-bit numeric IP address into a simple, easy, and recognizable name.
  • When a user types a website name, the DNS server finds the IP address of that website and displays the result of the query.
  • Flat Name Space and Hierarchical Name Space are the two types of Name Spaces.
  • To have a hierarchical namespace, the domain namespace is used. We can define the name as an inverted tree structure with a root. The tree has a maximum of 128 levels.
  • The domain name that ends with a null string is known as FQDN, and the domain name, which does not end with a null string is known as PQDN.
  • The primary server loads all the information from its local disk, and the secondary server receives all the information from the primary server.
  • The domain namespace on the network is divided into generic domains, country domains, and inverse domains.
  • Query and response are two types of DNS messages, and both are of the same format. Query and response both contain some information.

If you find any mistake above, kindly email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.