Skip to main content

Command Palette

Search for a command to run...

DNS Record Types Explained

Updated
•5 min read•View as Markdown
DNS Record Types Explained

What is DNS ?

DNS stands for Domain Name System. DNS is a distributed and hierarchical system that acts as address book of the internet. It translates domain names into IP addresses to facilitate efficient communication between devices across the globe.

Analogy : How it works ?

  • Humans are good at remembering names (like google.com or facebook.com).

  • Computers do not understand names, they only understand IP Addresses (like 142.250.190.46).

When you want to call your friend, you look up their name in your contacts list to find their phone number. You don't memorise the number.

DNS does something similar but for websites:

  1. You type google.com into your browser.

  2. Your computer asks a DNS Server: "What is the IP address for google.com ?"

  3. The DNS Server replies: "It is 142.250.190.46."

  4. Your browser connects to that number to load the website.

Why is it needed ?

Without DNS, you would have to memorise a string of random numbers (IP addresses) for every single website you wanted to visit.

DNS Record Types

There are various type of DNS records, some of them are listed below:

1. A record (IPv4 address)

The most fundamental record type. It maps a domain name to an IPv4 address. The “A” in the A record stands for “address,” and it specifically stores IPv4 addresses.

This record also used in domain name system-based blackhole list (DNSBL). Here, the A record is used to determine whether an email sender is blacklisted for email spam.

Use Case: Pointing example.com to the server hosting the website.

example.com.    IN    A    93.184.216.34

2. AAAA record (IPv6 address/Quad A)

Similar to the A record, the AAAA (Quad A) record also stores an IP address. The difference is that while the A record stores IPv4 addresses, the AAAA record is used to store IPv6 addresses.

There are a limited number of IPv4 addresses, and we’re running out of them. This is why IPv6 was introduced, and why AAAA records are becoming more crucial and will play an even larger role in the future.

Use Case: Enabling access to the website via the newer IPv6 protocol.

example.com.    IN    AAAA    2606:2800:220:1:248:1893:25c8:1946

3. CNAME Record (Canonical Name Record)

CNAME is a DNS record type that points a domain name to another domain. Unlike A or AAAA records, CNAME records don’t store IP addresses – instead, they work with aliases that direct to the canonical name.

For example, users can access a website by typing www.example.com, which is set up as a CNAME for example.com. This means that typing www.example.com in the search bar will resolve to the same IP address as example.com.

Companies often use CNAME records to redirect users from one subdomain to another. For example, you could create a CNAME record for subdomain.example.com that points to example.com, ensuring that any requests to subdomain.example.com are redirected to example.com.

www.example.com.    IN    CNAME    example.com.

4. MX Record (Mail Exchange Record)

A mail exchange (MX) record, specifies the mail server responsible for accepting email messages on behalf of a domain. In other words, an MX record makes it possible to direct emails to a mail server.

MX (Mail Exchange) Record tells the internet, "Send emails for @example.com to this specific mail server (e.g., smtp.gmail.com)."

You can have multiple MX records for a single domain name. And this means is that you can have backup email servers. It includes a priority value (lower numbers indicate higher priority). The following shows an example of a domain with multiple MX records:

example.com.    IN    MX    10    mail1.example.com.
example.com.    IN    MX    20    mail2.example.com.

5. NS record (Name Server)

A name server record specifies which DNS server is authoritative for the domain. When a user opens a certain webpage, the NS record is responsible for pointing out the location of the IP address for that domain name.

In other words, the NS record helps point to where a web browser can find the IP address for a domain name. Usually, multiple nameservers are specified for a domain. For example, these could look like ns1.examplehostingprovider.com and ns2.examplehostingprovider.com.

example.com.    IN    NS    ns1.examplehostingprovider.com.
example.com.    IN    NS    ns2.examplehostingprovider.com.

6. TXT Record (Text Record)

This DNS record type allows domain owners to store text values in the DNS server. Services like Google often use TXT records to verify domain ownership.

Services like Google or Microsoft ask you to add a unique code to a TXT record to prove you actually own the domain.

Commonly used for email security (SPF, DKIM, DMARC) and domain ownership verification (e.g., for Google Search Console).

example.com.    IN    TXT    "v=spf1 include:_spf.google.com ~all"

7. PTR Record (Pointer Record)

This is opposite of an A record. It maps an IP address to a domain name. It is used in Reverse DNS lookups. It is Often used by email servers to verify that the sender's IP address matches the domain name it claims to be sending from.

34.216.184.93.in-addr.arpa.    IN    PTR    example.com.

8. SRV Record (Service Record)

It specifies port & IP addresses of servers for specific services. Used for protocols like VoIP, instant messaging etc.

9. SOA Record (Start of Authority)

This record stores key administrative information, including the admin’s email, the zone’s serial number, when the domain was last updated, and the primary authoritative name server.

The DNS Resolution Flow

Here is the step-by-step journey of how these DNS records interact when you navigate to www.example.com:

  1. The DNS Query: Your computer asks a DNS Resolver (usually provided by your ISP or a public one like Google's 8.8.8.8): "Where is www.example.com?"

  2. Finding the Authority (NS Records): The resolver works its way down the hierarchy:

    • It asks the Root servers for .com.

    • The Root servers refer it to the TLD servers for .com.

    • The TLD servers check their NS Records for example.com and provide the IP addresses of the Authoritative Name Servers for that specific domain.

  3. Resolving the Hostname (A, AAAA, CNAME): The resolver now queries the Authoritative Name Server for www.example.com.

    • Scenario 1 (Direct IP): The server returns an A record (IPv4) or AAAA record (IPv6). The resolution is complete.

    • Scenario 2 (Alias): The server returns a CNAME record pointing www.example.com to server1.example.com. The resolver now has to repeat the lookup process for server1.example.com to find its IP address.

  4. Connection: The browser receives the final IP address and initiates a TCP handshake to load the webpage.

More from this blog

Code Munch

13 posts