What are DNS records?

When deploying my Golang backend for a project on a Digital Ocean droplet, an important question surfaced: How could I point my existing domain to this server? The domain was ready and waiting, lacking only the crucial link to establish a connection.

So, later I found out that there are various configuration that need to be setup in order to get the domain and the server up and running

One of those crucial configurations is setting up DNS records. We'll explore the important DNS records one by one, but for now, let's establish the basics first.

What is DNS?

In short, DNS is the phonebook of internet.

Each web address that one recalls (such as google.com, x.com, linkedin.com) represents a domain. The primary function of the Domain Name System (DNS) is to convert these domain names into their corresponding IP addresses. For instance, google.com is translated to the IP address 8.8.8.8, and so forth.

How it works?

In reality, a comprehensive process occurs behind the scenes to determine the actual IP address from the domain. However, we will summarize it in a few points.

  1. Upon entering the domain into the search bar, the browser checks its cache for the IP address of the domain.

  2. If not found in the browser's cache, it then prompts the operating system (OS) to check its cache.

  3. In the event the OS cache also lacks the required information, the OS requests the resolver, typically managed by the Internet Service Provider (ISP), to ascertain the corresponding IP address.

  4. Should the resolver be unaware of the IP address, it seeks assistance from the root server, which possesses information about where to locate the Top-Level Domain (TLD) server, such as .com, .net, .org, etc.

  5. If the TLD server does not possess the necessary IP address, it directs the inquiry to the nameserver with the assistance of the domain registrar.

  6. Nameservers play a pivotal role as they possess the authentic IP address and provide responses to DNS queries.

Domain vs URL

A URL contains domain name of a website as well as other information like queries & parameters.

eg. google.com/search?q=Cristiano%20Ronaldo

DNS Records

A Records

A record refers to Address record, it maps the domain or the subdomain to a IPv4 address. They are used to point a domain or subdomain to the specific IP address where the associated web content or services are hosted.

TypeNameValueTTL
Agoogle.com192.168.9.014400
Aapp.google.com192.168.9.114400

TTL (Time To Live) refers to amount for which the IP address can be cached in the records.

CNAME Records

CName Record refers to Canonical name record, and is used to alias one domain to another. For example, if you have a subdomain "blog.example.com" and you want it to point to the same location as "www.example.com", you can create a CNAME record. This record would indicate that "blog.example.com" is an alias for "www.example.com."

TypeNameValueTTL
Aexample.com192.16.8.914400
Aapp.example.com192.16.8.314400
CNAMEblog.example.comakashsharma.com14400

This CNAME in the above table indicates that the subdomain blog.example.com is an alias to akashsharma.com

MX Records

MX records refer to Mail Exchange records. It helps in routing emails to the relevant servers. Each MX record consists of a priority value and a mail server hostname. The priority value indicates the order in which mail servers should be utilized, with lower values indicating higher priority

TypeNameValueTTL
MXakash.commail.akash.com (10)14400
MXakash.commail2.akash.com (20)14400

The above table says that, any email destined for the domain akash.com should be routed to the mail server at mail.akash.com. The priority of mail.akash.com (10) is higher than that of mail2.akash.com (20) hence it will chosen as the recipient of the email.

TXT Records

TXT or Text Records are mostly used to verify whether you are the owner of the domain or not, by simply associating some text to your domain.

TypeNameValueTTL
TXTakashsharma.comSome dummy text14400

NS Records

NS records refer to Name Server Records. They indicate the authoritative Name Servers for the domain.

TypeNameValueTTL
NSakashsharma.comns1.eg.com14400

There are a few more records that we can explore later, such as PTR (Pointer) records for reverse DNS lookups and SOA (Start of Authority) records that contain crucial domain information.

In summary, our exploration has equipped us with a foundational understanding of DNS, its operational mechanisms, and the significance of DNS records in the intricate landscape of computer networks.