<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[How DNS Records Route Internet Traffic]]></title><description><![CDATA[How DNS Records Route Internet Traffic]]></description><link>https://how-dns-records-route-internet-traffic.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Fri, 26 Jun 2026 17:39:49 GMT</lastBuildDate><atom:link href="https://how-dns-records-route-internet-traffic.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[TCP Working: 3-Way Handshake & Reliable]]></title><description><![CDATA[In the chaotic world of the internet, millions of "packets" of data are flying around every second. Without a strict set of rules, these packets would get lost, arrive out of order, or show up corrupted.
Imagine trying to send a book to a friend by m...]]></description><link>https://how-dns-records-route-internet-traffic.hashnode.dev/tcp-working-3-way-handshake-and-reliable</link><guid isPermaLink="true">https://how-dns-records-route-internet-traffic.hashnode.dev/tcp-working-3-way-handshake-and-reliable</guid><category><![CDATA[three way handshake]]></category><category><![CDATA[ChaiCode]]></category><category><![CDATA[Chaiaurcode]]></category><dc:creator><![CDATA[sourav halder]]></dc:creator><pubDate>Sun, 15 Feb 2026 17:48:32 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/dyUp7WPu5q4/upload/a7127320e510086dda9acb791dc1f46c.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In the chaotic world of the internet, millions of "packets" of data are flying around every second. Without a strict set of rules, these packets would get lost, arrive out of order, or show up corrupted.</p>
<p>Imagine trying to send a book to a friend by mailing each page in a separate envelope. Without a system, your friend might receive page 10 before page 1, or page 5 might never show up at all. <strong>TCP (Transmission Control Protocol)</strong> is the system that ensures the book arrives perfectly, page by page.  </p>
<hr />
<h2 id="heading-the-problem-what-happens-without-rules">The Problem: What Happens Without Rules?</h2>
<p>Imagine you're trying to have a conversation across a crowded, noisy room. You shout "Hello!" but the other person doesn't hear you. You yell louder. They catch part of it but miss some words. You repeat yourself. Messages arrive out of order. Chaos.</p>
<p>This is what happens when computers try to communicate over the internet without a protocol.</p>
<p><strong>The challenges:</strong></p>
<ul>
<li><p><strong>Packets get lost</strong> - Data travels through multiple routers and networks. Sometimes packets disappear.</p>
</li>
<li><p><strong>Packets arrive out of order</strong> - The internet routes packets independently. Packet #3 might arrive before packet #1.</p>
</li>
<li><p><strong>Packets get corrupted</strong> - Electrical interference or hardware errors can flip bits during transmission.</p>
</li>
<li><p><strong>No confirmation</strong> - If you send data, how do you know it was received?</p>
</li>
<li><p><strong>No flow control</strong> - A fast sender can overwhelm a slow receiver.</p>
</li>
</ul>
<p><strong>Without addressing these problems, the internet wouldn't work.</strong> You'd download corrupted files, web pages would load with missing pieces, and video calls would be unintelligible.</p>
<p>This is where TCP comes in.</p>
<hr />
<h2 id="heading-what-is-tcp-and-why-do-we-need-it">What is TCP and Why Do We Need It?</h2>
<p>TCP is a "connection-oriented" protocol. Unlike its faster, messier cousin UDP (which just throws data at the receiver), TCP insists on a formal introduction before any data is sent.</p>
<p>It was designed to solve three major problems:</p>
<ol>
<li><p><strong>Packet Loss:</strong> Data getting lost in transit.</p>
</li>
<li><p><strong>Out-of-Order Delivery:</strong> Data arriving in the wrong sequence.</p>
</li>
<li><p><strong>Data Corruption:</strong> Data getting mangled during the journey.</p>
</li>
</ol>
<hr />
<p><strong>TCP vs UDP:</strong></p>
<p>TCP isn't the only transport protocol. There's also <strong>UDP (User Datagram Protocol)</strong>, which is faster but unreliable. UDP just sends data and hopes for the best—no guarantees, no handshakes, no retransmissions.</p>
<ul>
<li><p><strong>TCP:</strong> Reliable, ordered, slow. Used for web browsing, email, file transfers.</p>
</li>
<li><p><strong>UDP:</strong> Fast, unreliable, no guarantees. Used for video streaming, gaming, DNS lookups.</p>
</li>
</ul>
<p>Choose TCP when you need reliability. Choose UDP when you need speed and can tolerate some loss</p>
<hr />
<h2 id="heading-the-tcp-3-way-handshake-establishing-a-connection">The TCP 3-Way Handshake: Establishing a Connection</h2>
<p>Before any data is sent, TCP establishes a connection using a <strong>3-way handshake</strong>. This ensures both client and server are ready to communicate.</p>
<p><strong>Think of it like a phone call:</strong></p>
<ul>
<li><p><strong>You:</strong> "Hello? Can you hear me?"</p>
</li>
<li><p><strong>Friend:</strong> "Yes, I can hear you. Can you hear me?"</p>
</li>
<li><p><strong>You:</strong> "Yes! Okay, let's talk."</p>
</li>
</ul>
<p>Only after this exchange do you start your actual conversation. TCP does the same thing.</p>
<h3 id="heading-the-three-steps">The Three Steps</h3>
<p>The handshake involves three messages:</p>
<ol>
<li><p><strong>SYN</strong> (Synchronize) - Client to Server</p>
</li>
<li><p><strong>SYN-ACK</strong> (Synchronize-Acknowledge) - Server to Client</p>
</li>
<li><p><strong>ACK</strong> (Acknowledge) - Client to Server</p>
</li>
</ol>
<p>After these three messages, the connection is established and data transfer can begin.</p>
<h3 id="heading-step-1-client-sends-syn">Step 1: Client Sends SYN</h3>
<p><strong>What happens:</strong></p>
<p>The client wants to establish a connection. It sends a packet with:</p>
<ul>
<li><p><strong>SYN flag</strong> set to 1 (this marks it as a synchronization request)</p>
</li>
<li><p><strong>Sequence number</strong> (let's say 1000) - a random starting number</p>
</li>
</ul>
<p><strong>Meaning:</strong> "Hi, I want to connect. My starting sequence number is 1000. Are you ready?"</p>
<p><strong>Technical details:</strong></p>
<pre><code class="lang-bash">Client → Server
SYN: 1
Sequence Number: 1000
</code></pre>
<p>The client is now in <strong>SYN_SENT</strong> state, waiting for a response.</p>
<h3 id="heading-step-2-server-sends-syn-ack">Step 2: Server Sends SYN-ACK</h3>
<p><strong>What happens:</strong></p>
<p>If the server is willing to accept the connection, it responds with:</p>
<ul>
<li><p><strong>SYN flag</strong> set to 1 (server also wants to synchronize)</p>
</li>
<li><p><strong>ACK flag</strong> set to 1 (acknowledging the client's SYN)</p>
</li>
<li><p><strong>Sequence number</strong> (let's say 5000) - the server's random starting number</p>
</li>
<li><p><strong>Acknowledgment number</strong> set to 1001 (client's sequence + 1)</p>
</li>
</ul>
<p><strong>Meaning:</strong> "I received your request. My starting sequence number is 5000. I'm ready. I'm expecting your next byte to be 1001."</p>
<p><strong>Technical details:</strong></p>
<pre><code class="lang-bash">Server → Client
SYN: 1
ACK: 1
Sequence Number: 5000
Acknowledgment Number: 1001
</code></pre>
<p>The server is now in <strong>SYN_RECEIVED</strong> state.</p>
<h3 id="heading-step-3-client-sends-ack">Step 3: Client Sends ACK</h3>
<p><strong>What happens:</strong></p>
<p>The client acknowledges the server's response:</p>
<ul>
<li><p><strong>ACK flag</strong> set to 1</p>
</li>
<li><p><strong>Sequence number</strong> 1001 (as the server expected)</p>
</li>
<li><p><strong>Acknowledgment number</strong> set to 5001 (server's sequence + 1)</p>
</li>
</ul>
<p><strong>Meaning:</strong> "Got it! I received your confirmation. Let's communicate."</p>
<p><strong>Technical details:</strong></p>
<pre><code class="lang-bash">Client → Server
ACK: 1
Sequence Number: 1001
Acknowledgment Number: 5001
</code></pre>
<p>The connection is now <strong>ESTABLISHED</strong> on both sides. Data transfer can begin.</p>
<h2 id="heading-visual-3-way-handshake">Visual: 3-Way Handshake</h2>
<pre><code class="lang-bash">CLIENT                                   SERVER
  │                                        │
  │  1. SYN (seq=1000)                     │
  │ ─────────────────────────────────────&gt; │
  │                                        │
  │  <span class="hljs-string">"I want to connect. My seq is 1000"</span>   │
  │                                        │
  │                                        │
  │  2. SYN-ACK (seq=5000, ack=1001)       │
  │ &lt;───────────────────────────────────── │
  │                                        │
  │  <span class="hljs-string">"Okay! My seq is 5000. I got yours"</span>   │
  │                                        │
  │                                        │
  │  3. ACK (seq=1001, ack=5001)           │
  │ ─────────────────────────────────────&gt; │
  │                                        │
  │  <span class="hljs-string">"Perfect! Connection established"</span>     │
  │                                        │
  │━━━━━━━━ CONNECTION ESTABLISHED ━━━━━━━│
  │                                        │
  │  Now data can flow both ways           │
  │                                        │
</code></pre>
<h2 id="heading-why-three-steps-why-not-two">Why Three Steps? Why Not Two?</h2>
<p>You might wonder: why does the client need to send a final ACK? Couldn't we establish the connection after just SYN and SYN-ACK?</p>
<p><strong>The reason:</strong> TCP is a two-way connection. Both sides need to:</p>
<ol>
<li><p>Announce their starting sequence numbers</p>
</li>
<li><p>Acknowledge the other side's sequence number</p>
</li>
</ol>
<p><strong>Two messages wouldn't be enough:</strong></p>
<ul>
<li><p>After SYN, the client knows the server is listening</p>
</li>
<li><p>After SYN-ACK, the server knows the client is listening</p>
</li>
<li><p>But the client doesn't yet know the server received confirmation</p>
</li>
</ul>
<p>The third ACK ensures both sides are synchronized and ready.</p>
<h2 id="heading-how-data-transfer-works-in-tcp">How Data Transfer Works in TCP</h2>
<p>Once the connection is established, data flows with sequence and acknowledgment numbers tracking everything.</p>
<h3 id="heading-sequence-numbers">Sequence Numbers</h3>
<p>Every byte of data has a sequence number. If the client sends 100 bytes starting at sequence 1001, those bytes are numbered 1001 through 1100.</p>
<p><strong>Example:</strong></p>
<p>Client sends 100 bytes of data:</p>
<pre><code class="lang-bash">Client → Server
Sequence Number: 1001
Data: [100 bytes]
</code></pre>
<p>The server receives it and acknowledges:</p>
<pre><code class="lang-bash">Server → Client
Acknowledgment Number: 1101
</code></pre>
<p>This ACK says: "I received bytes 1001-1100. I'm expecting byte 1101 next."</p>
<h3 id="heading-acknowledgments">Acknowledgments</h3>
<p>TCP uses <strong>cumulative acknowledgments</strong>. An ACK number means: "I've successfully received all bytes up to (but not including) this number."</p>
<p><strong>Example conversation:</strong></p>
<pre><code class="lang-bash">Client sends bytes 1001-1100
Server ACKs: 1101 (<span class="hljs-string">"Got everything up to 1100"</span>)

Client sends bytes 1101-1200
Server ACKs: 1201 (<span class="hljs-string">"Got everything up to 1200"</span>)

Client sends bytes 1201-1300
Server ACKs: 1301 (<span class="hljs-string">"Got everything up to 1300"</span>)
</code></pre>
<p>This continues until all data is transferred.</p>
<h3 id="heading-bidirectional-communication">Bidirectional Communication</h3>
<p>TCP is <strong>full-duplex</strong>, meaning both sides can send and receive simultaneously. Each direction has its own sequence numbers.</p>
<pre><code class="lang-bash">CLIENT                          SERVER
  │                               │
  │  Data (seq=1001-1100)         │
  │ ───────────────────────────&gt;  │
  │                               │
  │  Data (seq=5001-5200)         │
  │ &lt;─────────────────────────── │
  │                               │
  │  ACK (ack=5201)               │
  │ ───────────────────────────&gt;  │
  │                               │
  │  ACK (ack=1101)               │
  │ &lt;─────────────────────────── │
</code></pre>
<p>Both sides maintain their own sequence numbers and acknowledge the other side's data</p>
<hr />
<h2 id="heading-how-a-tcp-connection-is-closed">How a TCP Connection is Closed</h2>
<p>Just like establishing a connection requires a handshake, closing it also requires a proper procedure. TCP uses a <strong>4-way handshake</strong> for termination.</p>
<h3 id="heading-the-four-steps">The Four Steps</h3>
<ol>
<li><p><strong>FIN</strong> - Client to Server (or vice versa)</p>
</li>
<li><p><strong>ACK</strong> - Server to Client</p>
</li>
<li><p><strong>FIN</strong> - Server to Client</p>
</li>
<li><p><strong>ACK</strong> - Client to Server</p>
</li>
</ol>
<h3 id="heading-step-by-step-termination">Step-by-Step Termination</h3>
<p><strong>Step 1: Client Sends FIN</strong></p>
<p>The client is done sending data:</p>
<pre><code class="lang-bash">Client → Server
FIN: 1
Sequence Number: 1500
</code></pre>
<p>"I'm finished sending data."</p>
<p><strong>Step 2: Server Sends ACK</strong></p>
<p>The server acknowledges:</p>
<pre><code class="lang-bash">Server → Client
ACK: 1
Acknowledgment Number: 1501
</code></pre>
<p>"I got your FIN. I'm still processing."</p>
<p>At this point, the connection is <strong>half-closed</strong>. The client won't send more data, but the server can still send data to the client.</p>
<p><strong>Step 3: Server Sends FIN</strong></p>
<p>When the server is done:</p>
<pre><code class="lang-bash">Server → Client
FIN: 1
Sequence Number: 6000
</code></pre>
<p>"I'm finished sending data too."</p>
<p><strong>Step 4: Client Sends ACK</strong></p>
<p>The client acknowledges:</p>
<pre><code class="lang-bash">Client → Server
ACK: 1
Acknowledgment Number: 6001
</code></pre>
<p>"Got it. Connection closed."</p>
<p>The connection is now fully terminated.</p>
<h3 id="heading-why-four-steps">Why Four Steps?</h3>
<p>TCP is full-duplex—data flows in both directions independently. Each direction must be closed separately:</p>
<ul>
<li><p>Client → Server direction closes (FIN + ACK)</p>
</li>
<li><p>Server → Client direction closes (FIN + ACK)</p>
</li>
</ul>
<p>Total: 4 messages.</p>
<h2 id="heading-complete-example-loading-a-web-page">Complete Example: Loading a Web Page</h2>
<p>Let's trace a real-world scenario: you visit <a target="_blank" href="https://example.com"><code>https://example.com</code></a></p>
<p><strong>Step 1: DNS Lookup</strong> (not TCP, but necessary) Your browser resolves <a target="_blank" href="http://example.com"><code>example.com</code></a> to IP address <code>93.184.216.34</code></p>
<p><strong>Step 2: TCP 3-Way Handshake</strong></p>
<pre><code class="lang-bash">Browser → Server (93.184.216.34:443)
  SYN (seq=1000)

Server → Browser
  SYN-ACK (seq=5000, ack=1001)

Browser → Server
  ACK (seq=1001, ack=5001)
</code></pre>
<p>Connection established.</p>
<p><strong>Step 3: TLS Handshake</strong> (happens over TCP) HTTPS requires encryption, so a TLS handshake occurs here. We'll skip details.</p>
<p><strong>Step 4: HTTP Request</strong></p>
<pre><code class="lang-bash">Browser → Server
  Sequence: 1001
  Data: <span class="hljs-string">"GET / HTTP/1.1\r\nHost: example.com\r\n..."</span>

Server → Browser
  ACK (ack=1100)
</code></pre>
<p><strong>Step 5: HTTP Response</strong></p>
<pre><code class="lang-bash">Server → Browser
  Sequence: 5001
  Data: <span class="hljs-string">"HTTP/1.1 200 OK\r\n...&lt;html&gt;..."</span>

Browser → Server
  ACK (ack=7000)
</code></pre>
<p>Server may send multiple packets if the page is large.</p>
<p><strong>Step 6: Connection Termination</strong></p>
<pre><code class="lang-bash">Browser → Server
  FIN (seq=1100)

Server → Browser
  ACK (ack=1101)

Server → Browser
  FIN (seq=7000)

Browser → Server
  ACK (ack=7001)
</code></pre>
<p>Connection closed. Web page loaded.</p>
<p><strong>All of this happens in milliseconds.</strong></p>
<h2 id="heading-key-takeaways">Key Takeaways</h2>
<ul>
<li><p><strong>TCP is a reliable, ordered, connection-oriented protocol</strong> that solves the chaos of unreliable networks</p>
</li>
<li><p><strong>The 3-way handshake (SYN, SYN-ACK, ACK)</strong> establishes a connection and synchronizes both sides</p>
</li>
<li><p><strong>Sequence numbers and acknowledgments</strong> ensure data arrives in order and completely</p>
</li>
<li><p><strong>Retransmissions and timeouts</strong> handle packet loss</p>
</li>
<li><p><strong>Checksums</strong> detect corrupted data</p>
</li>
<li><p><strong>Flow control</strong> prevents fast senders from overwhelming slow receivers</p>
</li>
<li><p><strong>Congestion control</strong> prevents network overload</p>
</li>
<li><p><strong>The 4-way handshake (FIN, ACK, FIN, ACK)</strong> properly terminates connections</p>
</li>
<li><p><strong>TCP trades speed for reliability</strong> - it's slower than UDP but guarantees delivery</p>
</li>
</ul>
<hr />
<h2 id="heading-summary-why-tcp-is-the-backbone-of-the-web">Summary: Why TCP is the Backbone of the Web</h2>
<p>TCP is the unsung hero of the internet. While it adds a bit of "overhead" (extra time for handshakes and ACKs), it provides the <strong>guaranteed delivery</strong> that makes the modern web possible. Without it, every file download would be a gamble and every website would be a broken mess.</p>
]]></content:encoded></item><item><title><![CDATA[How DNS Records Route Internet Traffic]]></title><description><![CDATA[Ever wondered, when you type a URL (Uniform Resource Locator, or simply the address of a website) like www.example.com into your browser:

“Where on earth should this request go?”

The system that solves this mystery is DNS (Domain Name System) — oft...]]></description><link>https://how-dns-records-route-internet-traffic.hashnode.dev/how-dns-records-route-internet-traffic</link><guid isPermaLink="true">https://how-dns-records-route-internet-traffic.hashnode.dev/how-dns-records-route-internet-traffic</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[Chaiaurcode]]></category><category><![CDATA[ChaiCohort]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[webdev]]></category><category><![CDATA[dns]]></category><category><![CDATA[dns-records]]></category><dc:creator><![CDATA[sourav halder]]></dc:creator><pubDate>Thu, 22 Jan 2026 04:12:22 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769053156288/1bce59ba-31bf-42ef-b61d-37d565554bc7.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Ever wondered, when you type a URL (<strong>Uniform Resource Locator</strong>, or simply the address of a website) like <a target="_blank" href="http://www.example.com"><code>www.example.com</code></a> into your browser:</p>
<blockquote>
<p><strong>“Where on earth should this request go?”</strong></p>
</blockquote>
<p>The system that solves this mystery is <strong>DNS (Domain Name System)</strong> — often called the <em>phonebook of the internet</em>.<br />Computers understand numbers (IP addresses), while humans prefer names (domain names). DNS acts as the bridge between the two by translating human-friendly domain names into machine-understandable instructions.</p>
<p>Instead of hard-coding IP addresses everywhere, DNS uses <strong>records</strong> — small configuration entries that describe how different kinds of requests for a domain should be handled. Different record types exist for different jobs: some point to web servers, some route emails, and some declare who is actually in charge of the domain’s DNS.</p>
<p>In this blog, we’ll break down the most important DNS record types, understand <strong>why they exist</strong>, and see how they work together in <strong>real production systems</strong> — in a way that’s easy to follow and useful for interviews.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769053386453/9037a18e-bf18-439e-ae3f-255ab0b7a4f5.png" alt class="image--center mx-auto" /></p>
<hr />
<h2 id="heading-what-are-dns-records-and-why-do-they-exist"><strong>What Are DNS Records and Why Do They Exist?</strong></h2>
<p>A <strong>DNS record</strong> is a single row in the DNS “database” that says:</p>
<blockquote>
<p><em>For this name, here is how to handle a specific kind of request.</em></p>
</blockquote>
<p>Each record answers a specific question about a domain, such as:</p>
<ul>
<li><p>Where is the website hosted?</p>
</li>
<li><p>Where should email be delivered?</p>
</li>
<li><p>Who is responsible for managing the domain?</p>
</li>
</ul>
<p>Instead of providing one generic answer, DNS uses <strong>different record types</strong>, each with a focused responsibility.</p>
<p>Think of DNS as a traffic control system:</p>
<ul>
<li><p>Web traffic goes this way</p>
</li>
<li><p>Email traffic goes that way</p>
</li>
<li><p>Management and authority are handled separately</p>
</li>
</ul>
<p>Each DNS record has at least:</p>
<ul>
<li><p><strong>Name</strong> (e.g., <a target="_blank" href="http://example.com"><code>example.com</code></a>, <a target="_blank" href="http://api.example.com"><code>api.example.com</code></a>)</p>
</li>
<li><p><strong>Type</strong> (A, AAAA, CNAME, MX, NS, TXT, etc.)</p>
</li>
<li><p><strong>Value</strong> (IP address, another domain, mail host, or name server)</p>
</li>
<li><p><strong>TTL (Time To Live)</strong> — how long DNS resolvers can cache the answer</p>
</li>
</ul>
<p>In short, DNS records allow humans to use names instead of IP addresses, while ownership and configuration are cleanly delegated behind the scenes.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769053467298/70377535-1140-48d8-8f54-921b37e573c8.png" alt class="image--center mx-auto" /></p>
<hr />
<h2 id="heading-a-record-mapping-domain-names-to-ipv4-addresses">A Record: Mapping Domain Names to IPv4 Addresses</h2>
<h3 id="heading-what-problem-does-it-solve">What Problem Does It Solve?</h3>
<p>Computers do not understand domain names — they understand IP addresses.</p>
<p>An <strong>A (Address) record</strong> maps a domain name to an <strong>IPv4 address</strong>.<br />It answers the question:</p>
<blockquote>
<p><strong>“Which server IP should handle this request?”</strong></p>
</blockquote>
<p><strong>Example</strong></p>
<pre><code class="lang-plaintext">example.com → 93.184.216.34
</code></pre>
<p>When you type <a target="_blank" href="http://example.com"><code>example.com</code></a>, your browser first talks to a <strong>DNS resolver</strong> (also called a recursive DNS server). The resolver does the heavy lifting — querying the root name servers, the TLD server (<code>.com</code>), and finally the authoritative name server to obtain the A record.</p>
<p>This resolution happens <strong>before the TCP handshake</strong>. Without the A record, the browser has no IP address to send the initial <code>SYN</code> packet to.</p>
<h3 id="heading-real-world-usage">Real-World Usage</h3>
<ul>
<li><p>Websites hosted on AWS, Azure, or GCP</p>
</li>
<li><p>Backend APIs</p>
</li>
<li><p>Load balancers pointing to multiple servers</p>
</li>
</ul>
<hr />
<h2 id="heading-aaaa-record-mapping-domains-to-ipv6-addresses">AAAA Record: Mapping Domains to IPv6 Addresses</h2>
<h3 id="heading-what-problem-does-it-solve-1">What Problem Does It Solve?</h3>
<p>The internet is gradually moving from IPv4 to IPv6 due to address exhaustion.</p>
<p>An <strong>AAAA (Quad-A) record</strong> maps a domain name to an <strong>IPv6 address</strong>.<br />Functionally, it is the same as an A record — except it works with IPv6.</p>
<blockquote>
<p><strong>Question it answers:</strong><br />“Which IPv6 server should handle this request?”</p>
</blockquote>
<pre><code class="lang-plaintext">example.com → 2606:2800:220:1:248:1893:25c8:1946
</code></pre>
<h3 id="heading-real-world-usage-1">Real-World Usage</h3>
<ul>
<li><p>Modern cloud infrastructure</p>
</li>
<li><p>Mobile networks</p>
</li>
<li><p>IPv6-enabled ISPs</p>
</li>
<li><p>Dual-stack deployments (IPv4 + IPv6)</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769053990759/fddc0e63-4e66-434c-8eee-14b5a006839b.png" alt class="image--center mx-auto" /></p>
<hr />
<h2 id="heading-cname-record-domain-aliases-and-indirection">CNAME Record: Domain Aliases and Indirection</h2>
<h3 id="heading-what-problem-does-it-solve-2">What Problem Does It Solve?</h3>
<p>Sometimes, the DNS resolver reaches the authoritative name server and receives <strong>another domain name instead of an IP address</strong>.</p>
<p>This is where the <strong>CNAME (Canonical Name) record</strong> comes in.</p>
<p>The CNAME answers:</p>
<blockquote>
<p><strong>“This domain is an alias — where is the real one?”</strong></p>
</blockquote>
<p><strong>Example</strong></p>
<pre><code class="lang-plaintext">www.example.com → example.com
</code></pre>
<p>The authoritative server is effectively saying:</p>
<blockquote>
<p>“I don’t have an IP for <a target="_blank" href="http://www.example.com"><code>www.example.com</code></a>, but I can tell you it’s an alias for <a target="_blank" href="http://example.com"><code>example.com</code></a>.”</p>
</blockquote>
<p>The resolver then resolves <a target="_blank" href="http://example.com"><code>example.com</code></a> (often using cached root and TLD data) to obtain the final A or AAAA record.</p>
<h3 id="heading-real-world-usage-2">Real-World Usage</h3>
<ul>
<li><p>Cloud services (CloudFront, Azure App Service, GitHub Pages)</p>
</li>
<li><p>Avoiding IP changes when infrastructure changes</p>
</li>
<li><p>Cleaner DNS management</p>
</li>
</ul>
<h3 id="heading-key-points">Key Points</h3>
<ul>
<li><p>You <strong>cannot</strong> have a CNAME and other record types (A, MX, TXT) for the same hostname.</p>
</li>
<li><p>CNAMEs are usually avoided at the <strong>zone apex</strong> (<a target="_blank" href="http://example.com"><code>example.com</code></a>); instead, A/AAAA records are used.</p>
</li>
<li><p>If the IP behind <a target="_blank" href="http://example.com"><code>example.com</code></a> changes, the CNAME does not need updating — only the final A/AAAA record does.</p>
</li>
</ul>
<h3 id="heading-common-confusion-a-vs-cname">Common Confusion: A vs CNAME</h3>
<div class="hn-table">
<table>
<thead>
<tr>
<td>A Record</td><td>CNAME Record</td></tr>
</thead>
<tbody>
<tr>
<td>Points to an IP</td><td>Points to another domain</td></tr>
<tr>
<td>Final destination</td><td>Indirection</td></tr>
<tr>
<td>Simple &amp; direct</td><td>Flexible &amp; scalable</td></tr>
</tbody>
</table>
</div><hr />
<h2 id="heading-ns-record-who-controls-the-domain">NS Record: Who Controls the Domain?</h2>
<h3 id="heading-what-problem-does-it-solve-3">What Problem Does It Solve?</h3>
<p>An <strong>NS (Name Server) record</strong> specifies which DNS servers are <strong>authoritative</strong> for a domain.</p>
<p>It answers:</p>
<blockquote>
<p><strong>“Which servers have the final, official DNS records for this domain?”</strong></p>
</blockquote>
<p>When the resolver queries the TLD server (<code>.com</code>), the TLD responds with NS records saying:</p>
<blockquote>
<p>“I don’t know the IP, but these servers own the DNS for <a target="_blank" href="http://example.com"><code>example.com</code></a>. Go ask them.”</p>
</blockquote>
<h3 id="heading-where-the-ns-record-lives-delegation">Where the NS Record Lives (Delegation)</h3>
<p>NS records exist in <strong>two places</strong>:</p>
<ol>
<li><p><strong>Parent zone</strong> (e.g., <code>.com</code>): tells resolvers where authority is delegated</p>
</li>
<li><p><strong>Child zone</strong> (authoritative server): confirms it owns the zone</p>
</li>
</ol>
<h3 id="heading-the-chicken-and-egg-problem-glue-records">The “Chicken and Egg” Problem: Glue Records</h3>
<p>If a nameserver is inside the same domain it serves (e.g., <a target="_blank" href="http://ns1.example.com"><code>ns1.example.com</code></a>), the resolver needs its IP <em>before</em> it can query it.</p>
<p>To solve this circular dependency, the TLD server provides a <strong>Glue Record</strong> — an A record containing the IP of the nameserver.</p>
<blockquote>
<p><strong>Key takeaway:</strong><br />NS records say <em>who</em> to ask. Glue records say <em>how</em> to reach them.</p>
</blockquote>
<h3 id="heading-summary-table-for-the-end-to-end-flow"><strong>Summary Table for the "End-to-End" Flow.</strong></h3>
<table><tbody><tr><td><p><strong>Step</strong></p></td><td><p><strong>Who is talking?</strong></p></td><td><p><strong>What record is exchanged?</strong></p></td><td><p><strong>Purpose</strong></p></td></tr><tr><td><p><strong>1</strong></p></td><td><p>Resolver → Root</p></td><td><p>NS Record (for .com)</p></td><td><p>Find the TLD server.</p></td></tr><tr><td><p><strong>2</strong></p></td><td><p>Resolver → TLD</p></td><td><p>NS Record (for <a target="_self" href="http://example.com">example.com</a>)</p></td><td><p>Find the Authoritative server.</p></td></tr><tr><td><p><strong>3</strong></p></td><td><p>Resolver → Authoritative</p></td><td><p>A / CNAME / MX</p></td><td><p>Get the final answer (IP or alias).</p></td></tr></tbody></table>

<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769053974612/ff164eb5-9ec8-4ecf-9f14-d1dfeb00beb3.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-common-confusion-ns-vs-mx"><strong>Common Confusion: NS vs MX</strong></h3>
<table><tbody><tr><td><p>NS Record</p></td><td><p>MX Record</p></td></tr><tr><td><p>Controls DNS authority</p></td><td><p>Controls email routing</p></td></tr><tr><td><p>Used by DNS resolvers</p></td><td><p>Used by mail servers</p></td></tr><tr><td><p>Set at registrar level</p></td><td><p>Email specific</p></td></tr></tbody></table>

<hr />
<h2 id="heading-txt-record-storing-text-based-instructions-and-proof">TXT Record: Storing Text-Based Instructions and Proof</h2>
<h3 id="heading-what-problem-does-it-solve-4">What Problem Does It Solve?</h3>
<p>Sometimes DNS needs to store <strong>information</strong>, not routing data.</p>
<p>A <strong>TXT record</strong> stores arbitrary text used by external systems for verification and security.</p>
<blockquote>
<p><strong>Question it answers:</strong><br />“Can this domain prove or publish something?”</p>
</blockquote>
<p><strong>Example</strong></p>
<pre><code class="lang-plaintext">example.com → "v=spf1 include:_spf.google.com ~all"
</code></pre>
<p>This SPF record tells mail servers which systems are allowed to send email for the domain.</p>
<h3 id="heading-real-world-usage-3">Real-World Usage</h3>
<ul>
<li><p>SPF, DKIM, and DMARC</p>
</li>
<li><p>Domain ownership verification</p>
</li>
<li><p>SSL certificate validation</p>
</li>
<li><p>Third-party service integrations</p>
</li>
</ul>
<p><strong>Key Point:</strong><br />TXT records do <strong>not</strong> control traffic. They provide proof and configuration data.  </p>
<hr />
<h2 id="heading-final-thoughts-dns-is-simple-until-it-isnt">Final Thoughts: DNS Is Simple — Until It Isn’t</h2>
<p>DNS looks simple on the surface, but it quietly powers almost everything on the internet. Websites load, emails get delivered, and cloud systems scale — all because DNS answers one fundamental question correctly:</p>
<blockquote>
<p><strong>“Where should this request go?”</strong></p>
</blockquote>
<p>Each DNS record exists to answer a specific version of that question:</p>
<ul>
<li><p><strong>A / AAAA</strong> → Where is the server?</p>
</li>
<li><p><strong>CNAME</strong> → Is this an alias?</p>
</li>
<li><p><strong>MX</strong> → Where should email be delivered?</p>
</li>
<li><p><strong>TXT</strong> → Can this domain prove something?</p>
</li>
<li><p><strong>NS</strong> → Who controls the domain?</p>
</li>
</ul>
<p>In real production systems, these records work <strong>together</strong>, not in isolation. A single DNS change can enable global scale — or cause a global outage.</p>
<p>DNS isn’t about memorizing record types.<br />It’s about understanding <strong>traffic, ownership, and trust</strong> on the internet.  </p>
<hr />
<p><em>DNS Records: Interview Questions &amp; Answers</em></p>
<h3 id="heading-q1-what-are-dns-records-and-why-do-they-exist"><strong>Q1. What are DNS records and why do they exist?</strong></h3>
<p><strong>Answer:</strong><br />DNS records are instructions stored in DNS servers that tell the internet how to route requests for a domain. They exist to translate human-readable domain names into actionable information such as IP addresses, mail servers, or verification data.</p>
<p>Without DNS records, systems would not know:</p>
<ul>
<li><p>Where a website is hosted</p>
</li>
<li><p>Where emails should be delivered</p>
</li>
<li><p>Who controls a domain</p>
</li>
</ul>
<hr />
<h3 id="heading-q2-what-is-the-difference-between-an-a-record-and-a-cname-record"><strong>Q2. What is the difference between an A record and a CNAME record?</strong></h3>
<p><strong>Answer:</strong></p>
<ul>
<li><p>An <strong>A record</strong> maps a domain directly to an IPv4 address.</p>
</li>
<li><p>A <strong>CNAME record</strong> maps a domain to another domain name.</p>
</li>
</ul>
<p><strong>Key rule:</strong><br />A domain with a CNAME record <strong>cannot</strong> have other records like MX or TXT.</p>
<p><strong>Example:</strong></p>
<pre><code class="lang-plaintext">example.com      → A → 93.184.216.34
www.example.com  → CNAME → example.com
</code></pre>
<hr />
<h3 id="heading-q3-when-should-you-use-aaaa-records"><strong>Q3. When should you use AAAA records?</strong></h3>
<p><strong>Answer:</strong><br />AAAA records are used to map a domain to an <strong>IPv6 address</strong>.<br />They are increasingly important as IPv6 adoption grows.</p>
<p>In modern production systems, it’s common to configure <strong>both A and AAAA records</strong> so clients can connect using either IPv4 or IPv6.</p>
<hr />
<h3 id="heading-q4-how-does-email-routing-work-using-mx-records"><strong>Q4. How does email routing work using MX records?</strong></h3>
<p><strong>Answer:</strong><br />MX records specify which mail servers are responsible for receiving emails for a domain.</p>
<p>They include a <strong>priority value</strong>, where lower numbers are tried first.</p>
<p><strong>Example:</strong></p>
<pre><code class="lang-plaintext">example.com → MX 10 mail1.example.com
example.com → MX 20 mail2.example.com
</code></pre>
<p>If the first server fails, the second is used automatically.</p>
<hr />
<h3 id="heading-q5-what-is-a-txt-record-and-why-is-it-important"><strong>Q5. What is a TXT record and why is it important?</strong></h3>
<p><strong>Answer:</strong><br />TXT records store arbitrary text and are commonly used for:</p>
<ul>
<li><p>Domain ownership verification</p>
</li>
<li><p>Email security (SPF, DKIM, DMARC)</p>
</li>
<li><p>Service integrations (Google, Microsoft, GitHub)</p>
</li>
</ul>
<p>TXT records play a critical role in <strong>security and trust</strong> on the internet.</p>
<hr />
<h3 id="heading-q6-what-does-an-ns-record-do"><strong>Q6. What does an NS record do?</strong></h3>
<p><strong>Answer:</strong><br />NS records define <strong>which name servers are authoritative</strong> for a domain.</p>
<p>They establish <strong>control and delegation</strong>, not traffic routing.</p>
<p>Without correct NS records:</p>
<ul>
<li><p>DNS changes won’t propagate</p>
</li>
<li><p>Domains may stop resolving entirely</p>
</li>
</ul>
<hr />
<h3 id="heading-q7-can-a-single-domain-have-multiple-dns-records"><strong>Q7. Can a single domain have multiple DNS records?</strong></h3>
<p><strong>Answer:</strong><br />Yes. A domain typically has multiple DNS records working together.</p>
<p><strong>Example:</strong></p>
<ul>
<li><p>A / AAAA → Website access</p>
</li>
<li><p>MX → Email delivery</p>
</li>
<li><p>TXT → Security and verification</p>
</li>
<li><p>NS → DNS authority</p>
</li>
</ul>
<p>Each record answers a <strong>different routing question</strong>.</p>
<hr />
<h3 id="heading-q8-common-dns-interview-trick-question"><strong>Q8. Common DNS Interview Trick Question</strong></h3>
<p><strong>Question:</strong><br />Why can’t you use both CNAME and MX on the same domain?</p>
<p><strong>Answer:</strong><br />Because a CNAME replaces the domain name entirely with another name.<br />Allowing MX or TXT alongside it would create ambiguity during DNS resolution.</p>
<hr />
<h3 id="heading-q9-how-does-dns-relate-to-real-production-systems"><strong>Q9. How does DNS relate to real production systems?</strong></h3>
<p><strong>Answer:</strong><br />In production:</p>
<ul>
<li><p>Load balancers rely on DNS</p>
</li>
<li><p>Failover is often DNS-based</p>
</li>
<li><p>Cloud services depend heavily on DNS TTLs</p>
</li>
<li><p>Misconfigured DNS can cause global outages</p>
</li>
</ul>
<p>DNS is a <strong>critical infrastructure layer</strong>, not just a configuration detail.</p>
]]></content:encoded></item></channel></rss>