This article describes DNS basics.
Domain Name System (DNS) is a distributed system to store and process domain zone information. It is mainly used to map IP addresses of network nodes to human-readable names. However, such mapping is not the only DNS function. It also handles different types of resource records and solves a variety of tasks such as redirecting between domain names, load balancing among hosts, and linking certain services (such as mail service) to domains:
DNS is one of modern Internet pillars since knowing IP address of a requested host is critical to receiving a response to any Internet request. However, IP addresses are numerical values like 188.8.131.52, which are not human-readable. In addition, the core principle of IP address assignment in a network is uniqueness. Moreover, IP address is not something permanent: it may change when a host or hosting service provider changes, etc. All the above factors make network navigation by IP addresses complicated for a human.
DNS converts a symbolic name requested by a client to an IP address(es) of a server(s) responsible for this domain zone. At early stage of the Internet, IP address conversion was based on the content of «hosts” file prepared in the centralized manner and automatically distributed to each computer in a network. However, with the Internet growth, the need for a new mechanism arose, and in 1983 Paul Mockapetris developed it — DNS.
Key DNS features:
- Distributed storage and management – each DNS server must only store information about domains delegated to it, while responsibility for different nodes of the domain name tree rests with different parties.
- Data caching – a DNS server can temporarily keep some information about non-delegated domains to reduce overall traffic.
- Hierarchical structure – a node responsible for a domain zone can autonomously delegate lower-level nodes to other DNS servers.
- Backup – multiple logically and physically isolated DNS servers store and process information about any certain node, thus ensuring information accessibility even if one or more nodes fail.
Domain name hierarchy and delegation
Domain is a named branch in a name tree, including the node itself (for example, “.com” first-level domain) and its subordinate nodes (“example.com” second-level domain, “mail.example.com” third-level domain, etc.). To designate domain name hierarchy, the term level is used, specifying the node position in a tree. The less the level number, the higher the domain position in the tree.
- «.» – a zero-level domain;
- «.ru» – a first-level (top-level) domain;
- «example.com» – a second-level domain;
- «mail.example.com» – a third-level domain;
- and so on.
Look at the zero-level domain «.» (dot) also called a root domain. In practice, the dot is usually omitted (we type «example.com” instead of «example.com.»); in other words, specifying a root domain is not mandatory for IP address resolution. Most client programs (such as web browsers, etc.) add a zero-level domain automatically without showing it to a user. A domain name without a zero-level domain is called a relative domain name, while the name ending up with a dot is called a Fully Qualified Domain Name, or FQDN.
Domain zone – a part of a hierarchical domain name tree (for example, «.ru»), which is fully transferred for service to a particular DNS server (or, more frequently, to several servers) for subsequent delegation of responsibility for this domain and all subordinate domains («anyaddress.ru», «any.anyaddress.ru») to another party.
Delegation – transfer of responsibility for a specific branch of a domain name tree to another individual or organization. This procedure implements one of the core DNS principles – distributed record storage and request processing. During the delegation process, so-called glue NS records for a delegated child zone («example.com»), pointing to DNS servers of a party accepting the domain (for example, to DNS servers of our company) are added to resource records of a parent zone («.ru»). Since then, all resource records of the «example.com” second-level domain and all its subdomains («mail.example.com», etc.) are stored on DNS servers of this company, with parent zone «.ru» storing only NS records pointing to these servers.
DNS server – a host storing resource records and processing DNS queries. DNS server can autonomously resolve addresses within the zone it is responsible for («example.com» in the above example) or redirect requests for “foreign” zones to higher-level servers.
DNS client – a set of software tools to interact with DNS. Periodically, the DNS server itself acts as a client.
Key types of resource records
Resource Record (RR) – an information storage and transmission unit in DNS, which includes the following elements (fields):
- Name – name of a domain to which the record relates;
- Time To Live (TTL) – maximum permissible time of record storage by a non-responsible server;
- Type – a parameter defining the record purpose and format in the data field (Rdata);
- Class – a data network type (it is meant that DNS also supports non-TCP/IP networks);
- Data field length (Rdlen);
- Data field (Rdata) – field content and format depend on record type.
The most used resource record types are:
- A (IPv4 Address Record) – links a domain name with a host IPv4 address;
- AAAA (IPv6 Address Record) – links a domain name with a host IPv6 address (similar to the А record);
- CNAME (Canonical Name Record) – used for redirecting to another domain name;
- MX (Mail Exchange) – refers to a mail server, which serves the domain;
- NS (Name Server) – refers to a DNS server responsible for the domain;
- TXT – domain text description. It is often required for special tasks (such as domain ownership right confirmation when linking it to mail service);
- PTR (Point to Reverse) – links a machine IP address to a domain and is used mainly by third-party mail services to check emails sent through this machine for relation to a domain specified in mail server parameters. If parameters do not match, an email is checked more thoroughly by other criteria.
Recursive and non-recursive DNS queries
Recursion is a model of query processing by a DNS server, when it performs full search of information (including information about domains, which are not delegated to it) and accesses other DNS servers if necessary.
DNS queries from a client (server) to a server may be recursive or non-recursive. In the first case, a DNS server that received a query polls all nodes in descending order of zone levels until it receives positive response or information that the requested domain does not exist. In case of a non-recursive query, the server returns positive response if only the queried node is within the domain zone for which this server is responsible. Non-recursion may be due to both query type and prohibition to perform such queries at the level of a DNS server itself:
Caching is another important DNS feature. When, during a recursive query fulfillment, DNS server polls other nodes, it may temporarily cache information contained in responses it receives. In this case, a repeated domain query does not go beyond DNS server’s cache. Maximum permissible caching time is specified in TTL field of a resource record.