Networking Basics: What's a DNS Server?

SayanSayan
4 min read

In the vast labyrinth of the internet, there exists a silent hero: the DNS server. It's like a phone-book but for the Internet. Just like we can search for the name of a person in our contact list to get their phone number, we (or, in this case, our web browser) can query a DNS server to get the corresponding IP Address for an URL. This simple but essential piece of the puzzle silently guides us through the digital landscape with effortless precision, making the internet accessible and navigable for billions worldwide.

Understand how URL Resolution works.

Let's say you want to visit https://hashnode.com/.You would open the web browser and type in the URL, and it opens after a while. That's all the user sees. Now, let's understand how the process works.

  • You type in the URL: https://hashnode.com/

  • Your computer doesn't exactly know where this URL is located or what it even means, since the Internet works based on IP Addresses. So, you would need a device that `translates` these URLs to IP Addresses. A DNS server does exactly that.

We usually type in the URLs of sites we want to visit, but the Internet works based on IP Addresses. So, DNS servers translates URLs to IP Addresses.

  • So, the computer first sends the URL to the DNS server, and the server returns it's IP Address.

  • Next, the computer sends a request to the IP Address, and the web server then sends back all the data the browser needs.

  • Finally, the received data is shown in the form of a webpage.

See it in action.

The dig command can be used to get information on the corresponding IP Address of an URL.
Note: Install bindutils or bind-tools if the command doesn't work.

$ dig hashnode.com
; <<>> DiG 9.18.26 <<>> hashnode.com
;; global options: +cmd
;; Got answer:
...

;; QUESTION SECTION:
;hashnode.com.            IN    A

;; ANSWER SECTION:
hashnode.com.        76    IN    A    76.76.21.21

;; AUTHORITY SECTION:
hashnode.com.        148832    IN    NS    eva.ns.cloudflare.com.
hashnode.com.        148832    IN    NS    duke.ns.cloudflare.com.

;; ADDITIONAL SECTION:
...

;; Query time: 3 msec
;; SERVER: 10.69.0.177#53(10.69.0.177) (UDP)
;; WHEN: Tue May 07 17:24:59 IST 2024
;; MSG SIZE  rcvd: 400

Let's understand what it all means:

  • QUESTION SECTION: The query we gave it.

  • ANSWER SECTION: This section tells us the result. We can see that the URL is being resolved to the IP Address 76.76.21.21, located in IN (India). The DNS Record Type is A (IPv4).

  • AUTHORITY SECTION: This section will return the list of name-servers that are the ultimate authority for resolving the query.

  • SERVER: This is the DNS server that resolved the query. In my case, it's my personal DNS server which is up-streamed to CloudFlare's DNS (1.1.1.1).

Understand where a DNS server fits in.

So now we have a rough idea about what a DNS server does. But where exactly does it fit in?

Short Answer: It lies right after the Internet Gateway. The Gateway is responsible for routing the URL information to the predefined DNS server.

Long answer: Usually, there isn't a one-size-fits-all answer to this. There are 3 types of DNS servers, listed here in a heirarchical manner:

  • Local DNS Server: Many networks have a local DNS server within the network itself. This server holds information about the local network devices and their IP addresses, as well as caching frequently accessed external domain names.

  • ISP DNS Server: Internet Service Providers (ISPs) often provide DNS servers for their customers. These servers are usually located within the ISP's network infrastructure.

  • Public DNS Server: Public DNS servers, like those provided by Google (8.8.8.8, 8.8.4.4), CloudFlare (1.1.1.1, 1.0.0.1), or OpenDNS (208.67.222.222, 208.67.220.220), are located in various data centers across the world. These providers provide regional DNS servers all throughout the world and are sometimes preferred to ISPs DNS for security, privacy, reliability or performance.

  • Root DNS Servers: These are the foundational DNS servers at the top of the DNS hierarchy. They contain the authoritative information for the top-level domains (TLDs) like .com, .org, .net, etc. Root DNS servers are distributed globally and maintained by different organizations, such as ICANN and Verisign.

In addition to this, we also have upstream DNS servers, which either resolve the queries themselves or send them to another DNS server, depending on a predefined set of rules.

Conclusion

In conclusion, DNS servers play a vital yet often overlooked role in the functioning of the internet. Understanding the significance of DNS servers empowers users to navigate the internet more effectively and appreciate the complexity underlying its seemingly simple processes.

In subsequent blogs, I'll also describe how you can self-host your own DNS server and setup a lot of network-level filtering rules and what not! Stay tuned for updates!

11
Subscribe to my newsletter

Read articles from Sayan directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Sayan
Sayan

I'm just another engineering student from a Tier 3 college, hoping to make it big someday.