How Domain Name System (DNS) Works?
Tags: beginners, distributedsystems, devops, discuss
Published: 2021-04-16 08:13:47

![](http://i.imgur.com/IOyLj4i.jpg)

A Domain Name System (DNS) translates a domain name such as [www.google.com](http://www.google.com) to an IP address.

DNS is hierarchical, with a few authoritative servers at the top level.  Your router or ISP provides information about which DNS server(s) to contact when doing a lookup.  Lower level DNS servers cache mappings, which could become stale due to DNS propagation delays.  DNS results can also be cached by your browser or OS for a certain period of time, determined by the [time to live (TTL)](https://en.wikipedia.org/wiki/Time_to_live).

* **NS record (name server)** - Specifies the DNS servers for your domain/subdomain.
* **MX record (mail exchange)** - Specifies the mail servers for accepting messages.
* **A record (address)** - Points a name to an IP address.
* **CNAME (canonical)** - Points a name to another name or `CNAME` ([google.com](http://google.com) to [www.google.com](http://www.google.com)) or to an `A` record.

Services such as [CloudFlare](https://www.cloudflare.com/dns/), [GoDaddy](https://in.godaddy.com/) and [Route 53](https://aws.amazon.com/route53/) provide managed DNS services.  Some DNS services can route traffic through various methods:

* [Weighted round robin](https://www.g33kinfo.com/info/round-robin-vs-weighted-round-robin-lb)
    * Prevent traffic from going to servers under maintenance
    * Balance between varying cluster sizes
    * A/B testing
* Latency-based
* Geolocation-based

### How DNS Servers Benefit Users ?

So, why is a DNS system really necessary? Let’s take a moment to put this in perspective. NetCraft’s April 2020 Web Server Survey reports that there are 1,246,121,153 sites across 260,089,947 unique domains in existence on the internet. Do you think you’d be able to remember even a minute fraction of those IP addresses of all the websites you want to visit?

DNS servers mean that if you wanted to visit Apple’s official website, instead of having to remember their IP address (Ex: 17.254.0.91), you’d be able to simply type in “apple.com” and your web browser seemingly retrieves the correct information from the appropriate web host server.

Some additional DNS server uses and features also include:

* **Load balancing**: One of the advantages that comes to mind with DNS is that it can help optimize performance. It does this by routing traffic from high-traffic areas of your network to ones with lower traffic.
* **Traffic rerouting**: In the event that something goes wrong, a DNS can be used to redirect traffic through different channels if something goes wrong with your network infrastructure.
* **Content blocking**: Don’t want your employees to be able to access specific websites from your network? DNS filtering can enable you to block known phishing sites or other harmful or inappropriate websites.

### Disadvantages :

* Accessing a DNS server introduces a slight delay, although mitigated by caching described above.
* DNS server management could be complex and is generally managed by [governments, ISPs, and large companies](http://superuser.com/questions/472695/who-controls-the-dns-servers/472729).

<hr>
## Thank you for reading
### If you like what you read and want to see more, please support me with  [coffee or a book](https://www.buymeacoffee.com/vishnuchi)  ;)