What Is DNS And How Does It Work?

Jul 3, 2019 | DNS

Even if you’ve never heard of DNS before, you may be surprised to know that you actually use it every day.

DNS stands for Domain Name System. It’s the way your device finds the website or email recipient you’re looking for. If you ask your computer to bring up google.com in your web browser, it has no idea what that means. Instead, your computer converts that domain name into a format that computers can understand.

The following is a DNS lookup performed on a Linux-based computer:

$ dig +short google.com
216.58.199.46

We’ve just asked the computer to find out the IP address of google.com. Our computer now understands that google.com lives at the address 216.58.199.46.

But, how does this work? Who stores all of this information?

There is no central location for every single DNS record on the internet. It’s a world-wide network of DNS servers working together to convert human readable names into IP addresses.

What you may not know is there’s an invisible dot at the end of every web address. For example: ‘google.com.’

If you visit a web address with a dot on the end, it will still get you to the same place; why is this?

The dot refers to the DNS root. At the root of the Domain Name System, there are several root nameservers. These servers get the ball rolling to tell your computer where a website lives.

The DNS lookup process begins from the very right-hand side of the domain. As there is an invisible dot, it begins there first.

It’s also important to note that every device/computer has a DNS resolver responsible for making all of these DNS lookup requests. Your DNS resolver servers are usually automatically assigned and provided by your Internet Service Provider.

The general conversation between your computer and all relevant DNS servers would be as follows:

Computer: Hello DNS resolver, where can I find google.com?
DNS Resolver: Hmm, I’m unsure, I’ll ask the root nameservers.

DNS Resolver: Hello ‘root’ nameservers, where can I find google.com?
Root Nameservers: Ask the .com nameservers, those servers will know.

DNS Resolver: Hello .com nameservers, where can I find google.com?
.com Nameservers: Ask Google’s nameservers, those servers will know.

DNS Resolver: Hello Google nameservers, where can I find google.com?
Google Namservers: Ahh! That website resides at 216.58.199.46.

The DNS resolver will then pass the answer back to the computer that requested the DNS lookup.

To see this entire process, see below:

$ dig +trace google.com

; <<>> DiG 9.9.5-3ubuntu0.18-Ubuntu <<>> +trace google.com
;; global options: +cmd
.                       3538    IN      NS      d.root-servers.net.
.                       3538    IN      NS      e.root-servers.net.
.                       3538    IN      NS      f.root-servers.net.
.                       3538    IN      NS      g.root-servers.net.
.                       3538    IN      NS      h.root-servers.net.
.                       3538    IN      NS      i.root-servers.net.
.                       3538    IN      NS      j.root-servers.net.
.                       3538    IN      NS      k.root-servers.net.
.                       3538    IN      NS      l.root-servers.net.
.                       3538    IN      NS      m.root-servers.net.
.                       3538    IN      NS      a.root-servers.net.
.                       3538    IN      NS      b.root-servers.net.
.                       3538    IN      NS      c.root-servers.net.
;; Received 717 bytes from 192.168.1.1#53(192.168.1.1) in 184 ms

com.                    172800  IN      NS      m.gtld-servers.net.
com.                    172800  IN      NS      i.gtld-servers.net.
com.                    172800  IN      NS      h.gtld-servers.net.
com.                    172800  IN      NS      e.gtld-servers.net.
com.                    172800  IN      NS      j.gtld-servers.net.
com.                    172800  IN      NS      d.gtld-servers.net.
com.                    172800  IN      NS      l.gtld-servers.net.
com.                    172800  IN      NS      b.gtld-servers.net.
com.                    172800  IN      NS      a.gtld-servers.net.
com.                    172800  IN      NS      c.gtld-servers.net.
com.                    172800  IN      NS      g.gtld-servers.net.
com.                    172800  IN      NS      k.gtld-servers.net.
com.                    172800  IN      NS      f.gtld-servers.net.
;; Received 1170 bytes from 192.112.36.4#53(g.root-servers.net) in 329 ms

google.com.             172800  IN      NS      ns2.google.com.
google.com.             172800  IN      NS      ns1.google.com.
google.com.             172800  IN      NS      ns3.google.com.
google.com.             172800  IN      NS      ns4.google.com.
;; Received 772 bytes from 192.41.162.30#53(l.gtld-servers.net) in 317 ms

google.com.             300     IN      A       216.58.199.46
;; Received 55 bytes from 216.239.34.10#53(ns2.google.com) in 117 ms

The final nameservers that provide the exact location are typically referred to as Authoritative Nameservers.

As you can see, there are several steps in the process and each step is crucial to the whole DNS lookup process.

So if you’ve ever edited your DNS records in your web hosting control panel, you’re adjusting the DNS records at the Authoritative Nameserver level.

Does it perform this DNS lookup process every single time?

Not necessarily.

In order to speed up the DNS lookup process and alleviate pressure on the the Domain Name System, caching is used.

Caching will occur at various levels in the DNS lookup process, including but not limited to:

  • Your device/computer
  • Your router
  • A proxy server
  • Your Internet Providers DNS resolver servers

It is possible for the answer to a DNS lookup to be provided by one of these instead of performing the entire lookup starting at the root nameservers.

How long is DNS cached for?

Each DNS record has a TTL (Time To Live) value which can be adjusted by the domain owner/administrator.

You’ll notice some numbers in the DNS trace above, these are the TTL values.

You’ll find that Google’s Authoritative Nameservers are providing a TTL of 300 seconds for google.com. This means that if any caching occurs at any level, Google is requesting that this DNS record is only cached for 300 seconds before a brand new DNS lookup needs to happen when the next request is made.

So now you know what DNS is and how it works!

If you have any questions or require assistance with any DNS adjustments, please open a support ticket.