What is DNS and How is it Used

In this post we provide a brief primer on DNS and how it is used

What is DNS and How is it Used

DNS is one of the foundational aspects of the internet; it allows you to use pretty URLs like devrev.ai instead of 74.15.256.23. This is an introductory post in a series of posts on some DNS hacks and best practices we use at DevRev.

Here’s the full list of posts for this series:

DNS explained (normal terms)

Imagine that you want to send a message to your friend, but instead of using their name, you only have their phone number. In this case, you would need to look up their name in a phone book to know who to call.

Similarly, when you type in a website address, like www.google.com, your computer doesn’t know where to find that website. Instead, it needs to look up the website’s IP address, which is like a phone number for websites.

This is where DNS comes in. DNS stands for “Domain Name System,” and it’s like a giant phone book for the internet. When you type in a website address, your computer sends a request to a DNS server, asking for the IP address of that website.

For example, to initiate communication with foo.bar.com, you need to know which IP address to start communication with, DNS is the system that provides that translation.

DNS explained (banana terms)

Okay, so imagine you have a bunch of bananas, each with a different name on it. These names represent website addresses, like www.google.com or www.youtube.com.

Now, you want to access one of these websites, but you don’t know which banana to pick. So, you take your bunch of bananas to a bunch of monkeys who are experts in finding bananas.

You ask the monkeys to find the banana with the name of the website you want to access. The monkeys know where to look, so they check their own bunch of bananas, which is like a big phone book for bananas.

Once the monkeys find the banana with the correct name, they give it to you. Now, you can peel the banana and enjoy the delicious fruit inside, which represents the website content you were looking for.

In DNS terms, the bunch of bananas with names on them represents the domain names of websites, while the monkeys represent DNS servers that help translate those names into IP addresses that computers can use to connect to the websites.

Record Types

Over the years DNS has evolved to support multiple record types, including but not limited to:

  • A (IPv4 Address)
    • An address record is the most traditional DNS record and is used to do simple host to IP mapping
    • Examples:
      • foo.bar.com --> 99.99.99.99
      • bas.bar.com --> 11.11.11.11
  • AAAA (IPv6 Address)
    • An address record is the most traditional DNS record and is used to do simple host to IP mapping
    • Examples:
      • foo.bar.com --> 2001:db8:3333:4444:5555:6666:7777:8888
      • bas.bar.com --> 2001:db8:3333:4444:CCCC:DDDD:EEEE:FFFF
  • CNAME (Canonical name aka Alias)
    • An alias record, will take one record (e.g., foo.bar.com) and return another host (A or CNAME) that it resolves to (e.g., bas.bar.com)
    • In this scenario, foo.bar.com is a CNAME that points to bas.bar.com
    • CNAME records cannot resolve to an IP address and must alway resolve to a host
    • There can be multiple CNAMEs in a chain but, they will need to eventually resolve to an IP address (in most cases)
    • In certain scenarios, CNAMEs may be used for domain ownership validation, however, TXT records are more commonly used for this purpose
    • Examples:
      • foo.bar.com --> bar.bas.com
  • MX (Mail exchanger)
    • Mail exchanger records, used for routing mail and points to the SMTP server for the particular domain
    • MX records can have multiple weights to prioritize some over others
  • TXT (Text)
    • TXT records are a generic text record (hence the name)
    • They are commonly used to store hints or data which can be queried via DNS
    • For example, TXT records are commonly used for:
      • Domain validation (ACME, etc.)
      • SPF/DMARC
    • Examples:
      • acme-validations... --> {known_hash}
essential