Understanding DNS: A Complete Guide
Humans prefer to use letters or words to communicate and browse the web as they are easier to understand and remember. Computers on the other hand don’t understand letters or words, they understand numbers. DNS bridges that gap between human and computer understanding.
Let’s understand DNS with a simple example of Google. When we search something on Google, we go to Google.com the DNS servers resolve this to the various servers of Google across the globe with identical information. The one closest to me would be 142.250.207.238. You can find the one closest to you by running ping google.com
in your terminal and then access through the browser which redirects to Google.com.
DNS
Let us now try to understand what DNS fully is. DNS(Domain Name System) is a system that will resolve domain names(which are alphanumeric) to IP addresses(IPv4 or IPv6).
Let us go back to our Google example to understand what happens. When we tell our browser to go to Google.com, it sends a request to a DNS server to search through its database to find a matching IP address for that domain name and once it finds that, it will send that back to your computer to communicate with the Google web server to retrieve the webpage, make searches, etc. It can be compared to old Yellow Pages which were telephone directories which had phone numbers of people and businesses. In those, we didn’t search for the phone numbers, rather we searched for the people’s names. DNS servers are those yellow page books.
Levels of DNS
DNS servers are at various levels, lets understand them.
Local cache: When you search for a website, your browser and OS will check their own cache to see if they have the IP address for the website stored. If they do, they will establish a connection with the server and move forward. If the IP is not present in the cache, it will go to the Resolver servers.
Resolver server: It is your ISPs server. When a resolver server receives a query, it will check its own cache to find an IP for the website. If it finds it, it will send it to the client(your computer) which will then establish a connection with the server and exchange information. Your computer will also store the website in its local cache then. If the resolver server cannot find the IP, it will send the query to a Root server.
Root servers: There are 13 sets of strategically placed root servers across the globe. Each set of these servers has a unique IP address. Root servers themself don’t know the IPs but they know which servers will. So, they direct the Resolver server to the appropriate TLD server.
Top Level Domain Server: There is one TLD server for each TLD(.com, .org, .net, .in, etc). They too like Root servers don’t themself know the IPs, so they redirect the resolver to the final DNS servers. The Authoritative Name Servers.
Authoritative Name Servers: They are responsible for knowing everything about the domain, including the IP address. So, when the Resolver server asks them for the IP of a website they respond with it. Finally, the Resolver server will send the IP to the client(your computer) which will then communicate directly with the website’s server. The Resolver will also store the IP in its cache memory incase someone else asks for it.
Here is a diagram for you to understand how DNS works with the example of google.com
DNS providers
There are many different DNS providers and they essentially all do the same thing, they act as an Authoritative Name Server. Some popular DNS providers are:
Cloudflare: Cloudflare is the leading DNS server provider. They also provide CDN, DDoS protection and many other features.
Amazon Route 53: It is a DNS provider by Amazon’s AWS.
Oracle Cloud DNS: It’s a DNS provider by Oracle Cloud.
Most domain registrars will also provide a DNS hosting but it may only have a limited number of records available or some other limits.
DNS records
In a DNS database there exists a DNS zone file. This zone file contains the DNS records. This file is on the Authoritative Name Servers.
Parts of DNS records
Any DNS record will have a few parts, let us understand each one of them.
Type: Specifies the type of DNS record. Example - A, AAAA, CNAME, etc
Name: It specifies the subdomain(or root if left blank) on which the record should be created.
Content: What the record points to it can be an IP, website, etc.
Proxy status: Unique to Cloudflare, specifies if Cloudflare should proxy the record.
TTL: The amount of time before the record is invalidated and has to be re-cached. For Cloudflare, Auto means 5 mins.
Types of DNS records
There are many types of DNS records but let’s talk about the most common ones.
A: It resolves a domain name(or subdomain) to an IP address(IPv4). What this means is that the domain(or subdomain) specified will display what the IP address is hosting.
-
AAAA: It resolves a domain name(or subdomain) to an IP address(IPv6). What this means is that the domain(or subdomain) specified will display what the IP address is hosting.
-
CNAME: Points a domain(or subdomain) to another domain(or subdomain). What this means is that the domain(or subdomain) specified will display what the website is hosting (in a nutshell explanation).
-
MX: It is used for sending emails. For example, if we send an email to
joe.doe@example.com
, our MTA(Mail Transfer Agent) will query the DNS server for example.com because it is looking for a mail server. The DNS server will respond back with for examplemail1.example.com
MX generally have 2 or more records one primary and the others secondary. They also have a priority, the lowest priority one will be the primary and higher priority will be secondaries incase the primary is overwhelmed or down.
-
NS: They provide the name of the authoritative name servers. They too generally have 2 records, primary and secondary. They actually reply to the DNS queries.
SRV: They point to a server and a service by including an IP and a port number.
TXT: They contain miscellaneous information about a domain. They are often used for verification of domain ownership, etc.
Conclusion
DNS (Domain Name System) translates human-readable domain names into IP addresses that computers understand. When you search for a website, your request goes through various levels of DNS servers: local cache, resolver server (your ISP's server), root servers, TLD servers, and finally authoritative name servers that provide the IP address. DNS providers like Cloudflare, Amazon Route 53, and Oracle Cloud DNS manage these processes. Various DNS records such as A, AAAA, CNAME, MX, NS, SRV, and TXT serve different functions like resolving domain names to IP addresses, email routing, and domain verification.
If you have any questions, please comment them or reach out to me via Discord and I will try my best to get back to you.
Subscribe to my newsletter
Read articles from Satindar directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by