It is not a simple task to know what the DNS is and how does it work. However, if you want to be more involved with the Internet, this is a very convenient knowledge to have.
What is DNS?
Domain Name System (DNS) is a hierarchical system for naming services, computers, and other resources connected to a private network or the Internet. At its core, a very important database has the register of domain names and their corresponding IP addresses.
On the Internet, humans but also machines communicate every day. Both use different codes to establish this contact. For people it is so much easier to use domain names to get what they are searching online but machines get in touch so much better with numbers (IP addresses).
When the Internet was born, the only code available was the machine one. Meaning, to reach a domain, it was needed to type on the browser its IP address. At this time, there were not the millions of domains we currently have but it was hard for people to remember more than a couple of numeric sequences such as 188.8.131.52 or 184.108.40.206.
The Domain Name System was created in favour of the people and it is officially working as the Internet’s infrastructure since 1985. We do not need to type numbers but easily memorize the domain names. As an example: instead of 220.127.116.11, we type on the browser deliciouspizza.com.
While humans use domain names, DNS will translate them (by using its database) into numbers (IP addresses) for machines to their tasks.
What is the domain name space?
It’s the organization required for networks, especially big ones, to operate. DNS is a hierarchical system. You can visualize it like an inverted tree, where the root is the highest level in the DNS hierarchy.
Root Level. The first step to resolve a domain name requested, is executed by the root servers located at this level. Moreover, here it has contained the list of the top-level domains existent in the world. For instance, takeaserver.com., the final dot on the right is the root level representation.
Top-level domain (TLD). Right below the root level is where the TLDs comes (.org, .com, .gov, .uk, .ru…). In takeaserver.com, the TLD is .com. The authoritative name server in this level will have a list of all .com registered domains.
Second-level domain. That is the level at which the organization (profitable, non- profitable, individuals…) is registering the domain name via domain register. Following our example, takeaserver.com, “takeaserver” is the second-level domain.
Subdomain. Mostly for big websites, it can be useful to add sections to the domain name for making easier their navigation and clearer their organization. As an example, news.takeaserver.com, or blog.takeaserver.com.
Different types of DNS servers
DNS is a big machinery that involves many different components to execute its daily tasks. Talking about the DNS resolution process, different types of servers participate in it.
Recursive server. It directly receives queries from users’ machines and searches for the necessary DNS information (different DNS records, IP address included) as for loading the domain name requested. In order to receive this information, the server can communicate through queries to other types of servers. Moreover, it can save DNS information on its cache during a defined period. This can accelerate the speed of the response. However, it is not its function to save information, as it is a searcher server.
This type of server will answer the users’ queries with the DNS information (DNS records) they requested or with error messages (according to the situation) if its search was not successful.
Root name server. The DNS translation explained previously must take place for machines to communicate and look for the IP address of the requested domain name. The necessary translation happens at this level, in a root name server.
This type of server operates for a specific zone and it can respond to queries for specific records of its corresponding zone. What is more, the server holds the list of the authoritative name servers for the different top-level domains (TLDs).
TLD name server. This server stores key information for domain names belonging to the same TLD (.com, .net, .mx, .uk, etc.). It knows the exact authoritative name server responsible for the different domains based on their TLD. When the server receives a query about a specific domain name, it will point an authoritative server out to continue the DNS resolution process.
Authoritative server. This server has a master of the DNS data. When records or any configuration is modified, added, or deleted, that happens only in the authoritative server (primary). It’s in charge of providing the updated information to the rest of the servers that requested it. The authoritative is the server that knows first-hand the associated IP address of a domain name.
There are primary and secondary authoritative servers. The primary one is the server that holds the DNS data and the only one that accepts modifications. Secondary ones are backups of the primary. They hold copies of the master data to provide redundancy. Secondary servers can query (updates of DNS data to the primary authoritative) and be queried by other servers.
How does DNS resolution work?
Every time you type a domain name to load a website, a complex DNS process is triggered.
Your browser sends a query to look for the corresponding IP address of the domain name you requested (example, takeaserver.com). A DNS recursive server gets this query immediately and will do its job searching for the necessary DNS data, in this case, an IP address. There is a possibility that this recursive find it in its cache. In that scenario, it will answer immediately the query for your browser to load the domain.
If that information is not in its cache anymore (there is an expiry time defined), it will ask the root server. Since this last stores all TLDs, it will point to the TLD server that corresponds to the domains you requested (.com, in the example takeaserver.com). What happens next is that the TLD will point out the exact authoritative server that can provide the IP address.
Once the recursive receives it from the authoritative server, finally, your browser’s query could respond with the correct IP address for loading successfully the domain (as example is takeaserver.com) you want to visit.
This complex process happens every time you type a domain name for visiting it. Sometimes you can be impatient if the loading takes more than three seconds but considering all the described processes, the time required for this process is amazing. Actually, in ideal conditions, it takes so much less, only milliseconds.
Types of DNS queries.
Queries trigger all the DNS machinery with different purposes. They are called DNS queries or DNS requests and are demands of DNS information (DNS records) that users send through their computers to a DNS recursive server. You already have the example of the search for the necessary IP address to load a domain. However, more DNS data (DNS records) could be queried.
There are different types of queries.
Recursive query. This happens when a user requests the IP address for a domain and all the DNS resolution process happens. A recursive server gets the query and asks other servers until an authoritative one provides it the DNS datum. This query occurs between the user’s computer and a recursive server.
Non-recursive query. The IP address associated with a domain could be looked by the users, who can ask the different servers until they get it to resolve the domain.
Iterative query. If the recursive server is not able to find the exact match (domain name requested-corresponding IP address), through the common recursive query, and the iterative query starts. This query occurs between the recursive server and other DNS servers and it provides to the user the best or the closest result it finds, a reference. This query’s process will work all the way down the DNS servers until it gets the reference, an error, or a timeout.
What the DNS records are?
DNS records could be classified as instructions that supply crucial information about domains. All these records are stored in the corresponding authoritative server of every domain.
DNS records are text-based and the way they are written is known as DNS syntax. They look like strings of different characters and everyone has specific functions. Combined, their possibilities are wide. DNS servers constantly use these records. They work as commands that tell them what to do.
DNS records have a specific time-to-live (TTL). It is established directly by administrators based on their specific needs.
DNS records you should know
There is a variety of DNS records, some of which are needed specifically for an access to websites through their domain name. Others offer a useful additional functionality.
A record. The letter “A” refers to “address”. This is a vital DNS record, which is responsible for linking hostnames with their associated IP addresses.
Records participate in the IP addresses’ search during the DNS resolution process. You request a domain and that kicks off the DNS resolution process. The search of the corresponding IP address across DNS servers occurs and finding that IP address means the recursive server finally got the A record of the requested domain that contains the IP address. The answer to a DNS query for loading a domain is an A record. It can be stored in the cache if configured and with it the IP address.
MX record. The Mail Exchanger record works directing mail to an e-mail server. Through it, you can identify the server or servers that are in charge of accepting e-mails for a domain. Without this record, e-mail sending servers would not have a reliable guide to operate.
PTR record. The Pointer record works exactly in the opposite direction of the A record. It supplies the associated domain names to IP addresses. They resolve reverse DNS searches. This means a user can send a query using an IP address and then the answer must be a domain name.
It is also important for securing the sending of e-mails. When a message is received, the receiver’s mail server will check the PTR record included on the message to verify that it really was sent from the domain (IP address) it claims. If PTR is not configured well, sent e-mails will go directly to spam.
CNAME record. The Canonical Name points to the real domain name of a domain or subdomain you look for. Using this record, you can forward subdomain queries to the main domain. It does not supply IP addresses, but it redirects to the domain where the client can get the IP address or other DNS records. It is used to facilitate the management of subdomains.
SOA record. The Start of Authority record holds key information about the DNS zone, administrative data about domains, and points to the authoritative name server (primary). Among the information it holds, you can find modifications, dates of those, the frequency for updates, time for secondary servers to wait before asking the primary a refresh, administrator’s e-mail address, etc.
TXT record. Text record saves text information about a domain to allow external “eyes” to read it. You can have many text records for different purposes. As a following example, to inform that you are the owner of a domain, to secure, when validating e-mailing or that you really are the owner of the domain.
Text records are so handy for administrators since they can write notes on them. They can use also text entries with instructions for DNS machines.
Without DNS infrastructure, the Internet would not be as practical and easy to use. Administrators and tech people know it well. However, if you want to run a business online, you should also have at least, a general picture in order to understand a bit more the “language” your IT team speaks. This will be helpful for you to make proper decisions.
The next article might be curious for you as well: