Demystify DNS - Tldr

Demystify DNS - Tldr

While setting up my blog I came across having to setup DNS entries for Github as well as Hashnode simultaneously. After reading about CNAME and A records I thought it would be fitting to do a short article on the subject.

What is DNS?

The Domain Name System (DNS) is analogous to a phonebook for the Internet. It lists domain names with their corresponding IP addresses (DNS Record).

Why do we need DNS?

It would be extremely tedious to remember and enter IP addresses for our favorite websites. Domain names were born to solve this problem by using letters rather than numbers allowing users to select easy to remember domain names for their websites. DNS is used to translates these domain names to IP addresses and eliminates the need for us to memorize any IP addresses.

How does DNS work?

DNS Flow (1).png

  1. The domain ‘joelcolaco.com’ is typed into a web browser and a DNS query is sent to the DNS resolver.

  2. The resolver queries a DNS root nameserver.

  3. The root nameserver responds to the resolver with the address of a Top Level Domain (TLD) DNS server. (In this example the .com TLD)

  4. The resolver makes a request to the .com TLD DNS server.

  5. The TLD DNS server responds with the IP address of the domain’s nameserver.

  6. The resolver sends a query to the Authoritative name server (domain’s nameserver). This is where if a zone file exists with a:

    • CNAME - a subdomain/domain can be pointed to another domain name which is returned to the resolver
    • A Record - a domain is mapped to an IP which is returned to the resolver
  7. If a domain name is returned we restart the process with the new domain provided to the resolver. If an IP address is returned it is provided to the resolver from the authoritative nameserver.

  8. The DNS resolver responds to the browser with the IP address of the domain requested.

  9. The browser makes a HTTP request to the IP address.

  10. The server at that IP returns the webpage to be displayed in the browser.

Common DNS Record Types

  • A: Map a domain name to IPv4 addresses
  • AAAA: Map a domain name to IPv6 addresses
  • CNAME: Canonical Name (CNAME) Record is used in the Domain Name System (DNS) to map one domain name to another domain name.
  • PTR: Resolve IPv4 or IPv6 addresses to domain names
  • NS: Provides a list of the authoritative name servers responsible for the domain
  • MX: Provides the domain names of mail servers that receive emails on behalf of a domain
  • SOA: Provides details about a DNS zone; required for every DNS zone
  • TXT: Provides arbitrary information to be shared in text format