The Domain Name System (DNS) is a system that changes a domain name to an Internet Protocol (IP) address or vice versa.
As a human, when you look for a website, you type a domain name, such as facebook.com or hostingwiki.org. Meanwhile, web browsers can only identify a website with an IP address consisting of numbers. DNS translates the human-readable domain name to an IP address, so you can access the website without typing the numbers.
For instance, if you want to access Facebook, you don’t need to type IP address 184.108.40.206 on the address bar, and just type facebook.com.
In this article, I’m going to cover the definition of a DNS server, how you connect a domain name via the DNS server, and how DNS works.
What Is a DNS Server?
A DNS Server is a server machine that provides IP addresses of the requested websites to the web browser. Even though this has been set by default in each computer and Internet Service Provider (ISP), some people still rearrange DNS servers to speed up their internet connection.
The primary function of DNS servers is to answer the DNS queries. If we wouldn’t have the servers, you have to type every IP address of a website, which needs a lot of effort as humans hardly remember numbers.
A DNS server also has other functions.
- Mapping IP addresses and domain names around the world.
- Searching the relevant answer for DNS queries from the user.
- Sending an email by searching the exact IP addresses relating to the email addresses.
- Securing data transfer between your computer and network when you access a website.
There are three DNS servers that work together to translate domain names to IP addresses. They are recursive DNS resolvers, TLD nameservers, and authoritative nameservers. I will cover the details when we dive deeper into the DNS.
Besides a DNS server, there are other important terms in the DNS technical process.
- DNS client. Is a computer that contains DNS queries for DNS servers.
- DNS cache. Means temporary storage of DNS lookups’ previous results.
- DNS record. Contains important information about the IP address. Here are some of the DNS records.
- Address Record (A Record). Maps a domain or subdomain to its IP address. For example, it maps facebook.com to its IP address 220.127.116.11.
- CNAME. Updates a domain to another domain name whenever it changes. For example, it brings you to youtube.com when you type www.youtube.com.
- Reserve-lookup Pointer records. Allows you to type an IP address and get a domain name (reverse DNS lookup).
- Name Server Records (NS Record). Identifies which Authoritative Name Server is used for a particular domain name.
- Text Record (TXT Record). Holds text information for outside sources. Google uses this for domain ownership verification and email security.
- MX Entry. Sends email to a particular mail server.
- DNS query. Refers to a request sent from a DNS Client to a DNS Server. There are several queries in the DNS process.
- Recursive query. A DNS client requests a DNS server to give a response. There are two possible responses the DNS server delivers. First, relevant information that is available in the recursive DNS resolvers or Authoritative Name Server. Second, an error message when the resolver can’t find the correct answer.
- Iterative query. This query happens when a DNS resolver can’t find the answer in its database, so the query is forwarded to the Root Nameserver.
- Non-recursive query. This query is the fastest since the DNS resolver finds the DNS record in its cache and returns it to the user.
How Do You Connect to Your Domain Name via the DNS Server?
DNS exists to bridge the communication gap between numerical addresses and easier to memorize domains. Imagine DNS works as the phone book of the Internet. In your phone book, you don’t need to remember your friends’ phone numbers. You just type their names, then the number pops up.
Deeper Dive into DNS
Loading a webpage seems easy as it happens within seconds, but a lot is happening behind the scenes. There are four DNS servers contributing to loading a website.
Recursive DNS resolver
This server is your Internet Service Provider (ISP). Recursive DNS resolver receives DNS queries that include a human-readable hostname like www.facebook.com. This DNS server works like a librarian that gives you a direction on finding a particular book in the library.
When the DNS resolver gets the query, it will first check its own cache memory to find an IP address. It will return with the answer to the query immediately if it can find the DNS record. If the DNS record is not there, it will send the query to the next level: Root Name Server.
DNS Root Name Server
As the name suggests, the root nameserver is the top or the root of the DNS hierarchy. You can visualize this as an index in a library that tells the specific rack of the books you are looking for.
There are 13 sets of this type of DNS server, which are placed around the world. Those sets are indicated by the letter a to m and operated by 12 different organizations, including Verisign, the University of Southern California, and NASA.
Although there are 13 main root nameservers, those multiply into many copies for different zones. You can access detailed pages for all root servers on www.root-servers.org.
When the root nameserver receives the query from the DNS resolver, it doesn’t know the exact IP address yet. Instead, this server directs the resolver to the next level, the Top-Level Domain (TLD) Nameserver.
The Top Level Domain (TLD) server stores the address information for top-level domains, such as .net, .org, and .com. Here is a hierarchy of TLD components.
These are the last element of a hostname, which are classified into two sub-categories.
- Generic Top-Level Domain (gTLD)
- .com. For commercial organizations, like hostinger.com and microsoft.com.
- .edu. For educational institutions, like miamioh.edu and academia.edu.
- .gov. For government institutions, like usa.gov and ca.gov.
- .mil. For military groups, like norad.mil and marines.mil.
- .net. For network support centers, like slideshare.net and php.net.
- .org. For nonprofit organizations, like beloved.org and mozilla.org.
- .int. For international organizations, like era.int and nato.int.
- Country Code Top Level Domain (ccTLD)
Certain geographical areas use a ccTLD and usually connects it to the main TLDs. For instance, Indonesia has a ccTLD .id. It has .ac.id for academic institutions and .go.id for government institutions. Other popular ccTLDs are:
- .ca. For Canada.
- .eu. For European Union.
- .fr. For France.
- .uk. For the United Kingdom.
- .us. For the United States.
Second-level Domains (SLDs)
This level refers to the main element of your domain name. It represents who owns the domain. For example, the SLD of facebook.com is Facebook, and then the TLD is .com.
Third-level Domains (Sub-domains)
Sub-domains indicate a specific section of the main domain. For instance, support.google.com is a place to help the users tackle issues around the Google environment.
Thus, once this DNS server receives the query of a certain domain name, it will categorize based on the extension.
When it gets the request, TLD Nameserver still doesn’t know the IP address of the domain. But, it will direct the resolver to the next and final level, which is the Authoritative Nameserver.
Authoritative Name Server
The authoritative nameserver is the final server in the DNS as it stores the IP addresses of the requested hostnames. This server will return the correct IP address to the DNS Resolver, and you will see the webpage of the domain you are looking for on your screen.
After that, the DNS resolver will restore the DNS records in the cache for a short period of time, in case it gets the same request in the future.
Find the authoritative name server of a website from your computer by following the steps below.
- Search Command Prompt (CMD) on the menu for Windows users or click the Terminal icon on the Launchpad.
- Type nslookup after your computer username and hit enter.
- Type set query-ns and hit enter.
- Type the domain name you want to see the authoritative nameserver.
It will show you the registrar information, name servers, and important dates (when the domain is registered, expired, and updated). In this example, the registrar is Hostinger, while Nameservers are *.cloudflare.com. These nameservers belong to Cloudflare.
But, you may wonder how the TLD name server knows which authoritative nameserver that stores the proper IP address.
It all begins when you purchase a domain name from a registrar, for example, Hostinger. Next, you have to set up the DNS records for your domain and buy a hosting plan to store the records. One of the DNS records, the NS record, indicates which authoritative nameserver for your domain.
Once authoritative nameserver details are entered in the registrar, it will tell the TLD managing companies to update the TLD nameserver with the details of the authoritative nameserver for your domain.
Now, when the TLD nameserver receives the domain’s query, it already knows which authoritative nameserver provides the correct IP address of the domain.
Even though the loading process seems short, the translation of hostnames into IP addresses is a long journey. Hence, it may take a long time to figure out the IP address when you type the domain name for the first time. The DNS resolver still needs to ask for the address to different DNS servers.
How a DNS Lookup Actually Works
Now, the technical side has been explained. Let’s recap how we connect our domain names via the DNS servers by looking at the DNS lookup.
Without cache, the process starts from a user typing the domain name through the DNS servers and back to DNS resolver.
A user types a domain name. To make the explanation easier, I use facebook.com as the domain name. The type of DNS query in this process is Recursive query.
- DNS Resolver > Root Name Server
DNS resolver receives the request from the user and checks its cache to find the IP address of facebook.com. As it can’t find the IP address of the hostname, DNS now acts as a client. It forwards the request (Iterative query) to the first DNS server, Root Nameserver.
The root server will check the domain name’s extension, whether it’s .com, .net, or .uk. As the extension of Facebook is .com, the Root server will respond to the DNS resolver with the address of .com TLD Nameserver.
- DNS Resolver > TLD nameserver
Here, the DNS resolver asks for more information about the IP address to the TLD server. .com TLD Nameserver still doesn’t know the exact IP address of facebook.com. But, it gives the address of Authoritative Nameserver to the DNS resolver.
- DNS Resolver > Authoritative Nameserver
DNS resolver contacts the last DNS server, Authoritative Nameserver. This server stores complete information about the requested website. It eventually provides the exact IP address of facebook.com, which is 18.104.22.168, to DNS resolver.
- DNS Resolver > Computer’s operating system
After the DNS resolver gets the DNS record from the Authoritative Nameservers, it forwards the information to the computer’s operating system.
Then, the operating system will continue giving the information to the web browser. The web browser will contact the Facebook server and load the requested web page. Now, the user will see the homepage of facebook.com.
If the user types an unregistered domain name in the first place, the DNS resolver will send an error message.
The process above happens when the DNS resolver can’t find the IP address in its cache. If the information is there, the process will be faster as the DNS resolver doesn’t have to go through all those steps and immediately answers the request (Non-recursive query).
That’s the purpose of DNS caching. When a DNS resolver finally receives the complete IP address from Authoritative nameservers, it will save the information in temporary memory.
When you type the domain name in the future, the DNS resolver will immediately start from Step 5. But, if the cache is gone, you will proceed to a regular DNS lookup once more.
If you find the DNS servers are too slow, several methods can speed up the DNS lookup.
- Pick a good DNS servers service. I found the top three public DNS server services that offer good results. They are Cloudflare, Open DNS, and Google.
- Look at the ping from each service and choose the smallest one. Your location to the DNS service influences the speed. The ping tool helps you measure the destination time from one Internet host to another.
- Check the best server with DNS Benchmark (for Windows and Linux) or Namebench (for Windows, Linux, and Max). The tool compares the performance of your current DNS server with the alternatives.
Authoritative DNS Servers vs. Recursive DNS Servers
These terms refer to the kinds of DNS servers that play important roles in loading a website but have different functions. Recursive DNS servers (DNS resolvers) are placed at the top of DNS lookup, while Authoritative DNS servers are at the bottom of the DNS lookup.
- Recursive DNS servers
This server is provided by the ISP (Internet Service Provider). It receives a request from the client about the IP address of a certain domain name.
The recursive DNS resolver doesn’t know the exact IP address, but it will ask other DNS servers to find the address. Once it receives the answer from the last-stop server, the Authoritative DNS server, it will save the information and forward it to the client.
Recursive DNS servers don’t always ask for the IP address to other servers. If it finds the correct IP for the query in its cache, it will directly send the answer.
- Authoritative DNS servers
Authoritative DNS servers provide the correct IP address to the recursive DNS servers. It keeps all DNS resource records ranging from the IP addresses for domain names to mail servers.
Both servers work hand in hand but are not interchangeable.
Humans identify other things with names, like lions or smartphones. Meanwhile, computers communicate with each other by numbers.
To bridge the differences in networking, there is a system called Domain Name System (DNS). It is a system that translates a domain name to an Internet Protocol (IP) address. Thus, you don’t have to remember the IP address for each website you want to visit.
In the translation process, there are four DNS servers involved.
- Recursive DNS resolver. Gets DNS queries from a user and forwards them to other DNS servers.
- DNS Root Name Server. Directs the DNS resolver to the TLD Nameserver, based on the domain extension, like .com, .net, or .org.
- TLD Nameserver. Stores the information of TLDs and directs the DNS resolver to the final stop, Authoritative Nameserver.
- Authoritative Nameserver. Holds DNS records for the requested domain names and provides DNS resolver with the correct IP address.
After the DNS resolver receives the answer, it stores it in its cache memory in case the user needs it in the future and forwards it to the computer operating system. The computer operating system will connect to the web browser and the webserver to retrieve the web page.
Authoritative Nameserver and Recursive DNS servers (DNS resolver) work together, but not interchangeably.
DNS resolver is placed at the beginning of DNS lookup and forwards requests to other DNS servers. Meanwhile, the Authoritative nameserver is the final level of DNS lookup. It keeps the DNS records and answers the IP address of the requested website to the DNS resolver.
I hope this article helps you understand DNS, its related terms, and how it works. If you still have questions, feel free to drop them in the comments section below.