<?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[Code With Tejas]]></title><description><![CDATA[Code With Tejas]]></description><link>https://thetejascodes.hashnode.dev</link><image><url>https://cdn.hashnode.com/uploads/logos/69b2730b6c896b0519049468/a1671be4-9611-4fcb-a478-5db744343072.png</url><title>Code With Tejas</title><link>https://thetejascodes.hashnode.dev</link></image><generator>RSS for Node</generator><lastBuildDate>Tue, 13 Oct 2026 15:34:24 GMT</lastBuildDate><atom:link href="https://thetejascodes.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[I traced a DNS lookup step by step with dig. Here's what I found]]></title><description><![CDATA[In part 1, I explained what DNS records are. But I left one question open: who actually stores those records, and how does DNS find them out of the whole internet?
So I treated a DNS lookup like a gam]]></description><link>https://thetejascodes.hashnode.dev/i-traced-a-dns-lookup-step-by-step-with-dig-here-s-what-i-found</link><guid isPermaLink="true">https://thetejascodes.hashnode.dev/i-traced-a-dns-lookup-step-by-step-with-dig-here-s-what-i-found</guid><category><![CDATA[dns]]></category><category><![CDATA[networking]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[#beginners #learningtocode #100daysofcode]]></category><category><![CDATA[Linux]]></category><category><![CDATA[chaicode webdev cohort 2026]]></category><category><![CDATA[ChaiCode]]></category><category><![CDATA[Chaiaurcode]]></category><dc:creator><![CDATA[Tejas Kishan Kale]]></dc:creator><pubDate>Tue, 13 Oct 2026 12:36:19 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/69b2730b6c896b0519049468/6376e77d-9122-4c32-9d13-e222091e5762.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In <a href="https://thetejascodes.hashnode.dev/how-does-a-browser-know-where-a-website-lives">part 1</a>, I explained what DNS records are. But I left one question open: who actually stores those records, and how does DNS find them out of the whole internet?</p>
<p>So I treated a DNS lookup like a game: three levels and a boss, with <code>dig</code> as my tool. If you read part 1 and want to see what happens underneath, this post is for you.</p>
<hr />
<h2>Quick recap: what is DNS?</h2>
<p>DNS is the phonebook of the internet. People remember names like <code>google.com</code>, but computers need numbers (IP addresses). DNS turns one into the other, and that is why name resolution exists.</p>
<hr />
<h2>The game map</h2>
<p>There is no single giant phonebook for the whole internet. DNS is split into layers, and each layer only knows who to ask next. Level 1 is the root servers, Level 2 is the <code>.com</code> servers, and Level 3 is google.com's own name servers. The boss at the end is the real answer: the IP address.</p>
<img src="https://cdn.hashnode.com/uploads/covers/69b2730b6c896b0519049468/150af921-1f77-490a-998d-4b3c084a5340.png" alt="Diagram: the game map, Root → .com → google.com name servers" style="display:block;margin:0 auto" />

<hr />
<h2>Your tool: <code>dig</code></h2>
<p><code>dig</code> is a terminal tool that asks DNS a question and shows you the raw answer. You use it when you want to see what DNS is really saying, for example when a site isn't opening or a record change hasn't shown up yet.</p>
<blockquote>
<p><strong>Real-life comparison:</strong> Think of <code>dig</code> as a magnifying glass for DNS. Your browser hides the lookup from you, and <code>dig</code> lets you see it.</p>
</blockquote>
<pre><code class="language-bash">dig -v
</code></pre>
<pre><code class="language-plaintext">DiG 9.20.24-1ubuntu0.3-Ubuntu
</code></pre>
<p>One honest note: by default, <code>dig</code> doesn't ask the root servers directly. It asks my resolver, which here is Google's public one at <code>8.8.8.8</code> (you can see <code>SERVER: 8.8.8.8</code> in every output). So Levels 1 to 3 show what each layer looks like. The bonus section after the boss shows the real walk.</p>
<hr />
<h2>Level 1: Ask the root with <code>dig . NS</code></h2>
<p>Every search has to start somewhere. For DNS, it starts at the very top, called the root.</p>
<blockquote>
<p><strong>Real-life comparison:</strong> Think of a directory for the whole country. It doesn't list every house, it only tells you which city directory to open next.</p>
</blockquote>
<pre><code class="language-bash">dig . NS
</code></pre>
<pre><code class="language-plaintext">;; ANSWER SECTION:
.  87203  IN  NS  m.root-servers.net.
.  87203  IN  NS  j.root-servers.net.
.  87203  IN  NS  f.root-servers.net.
.  87203  IN  NS  d.root-servers.net.
.  87203  IN  NS  i.root-servers.net.
.  87203  IN  NS  h.root-servers.net.
.  87203  IN  NS  l.root-servers.net.
.  87203  IN  NS  a.root-servers.net.
.  87203  IN  NS  g.root-servers.net.
.  87203  IN  NS  k.root-servers.net.
.  87203  IN  NS  e.root-servers.net.
.  87203  IN  NS  c.root-servers.net.
.  87203  IN  NS  b.root-servers.net.

;; SERVER: 8.8.8.8#53(8.8.8.8) (UDP)
</code></pre>
<p><strong>What I found:</strong> I got 13 root servers, named <code>a.root-servers.net.</code> to <code>m.root-servers.net.</code>, one letter each. The lone dot in <code>dig . NS</code> is the root itself, the level above <code>.com</code>. The number <code>87203</code> is the TTL, in seconds: how long a resolver may remember this answer. I ran the command again a minute later and it still said 87203, so this number does not always tick down on every resolver.</p>
<hr />
<h2>Level 2: Ask the TLD with <code>dig com NS</code></h2>
<p>The root doesn't know where google.com is, but it knows who handles <code>.com</code>. So the next question goes to the <code>.com</code> servers, also called TLD servers (TLD means top-level domain).</p>
<blockquote>
<p><strong>Real-life comparison:</strong> Now we're at the city directory. It doesn't list individual houses either, only which street to go to.</p>
</blockquote>
<pre><code class="language-bash">dig com NS
</code></pre>
<pre><code class="language-plaintext">;; ANSWER SECTION:
com.  21600  IN  NS  m.gtld-servers.net.
com.  21600  IN  NS  j.gtld-servers.net.
com.  21600  IN  NS  i.gtld-servers.net.
com.  21600  IN  NS  h.gtld-servers.net.
com.  21600  IN  NS  c.gtld-servers.net.
com.  21600  IN  NS  a.gtld-servers.net.
com.  21600  IN  NS  k.gtld-servers.net.
com.  21600  IN  NS  b.gtld-servers.net.
com.  21600  IN  NS  g.gtld-servers.net.
com.  21600  IN  NS  f.gtld-servers.net.
com.  21600  IN  NS  l.gtld-servers.net.
com.  21600  IN  NS  d.gtld-servers.net.
com.  21600  IN  NS  e.gtld-servers.net.

;; SERVER: 8.8.8.8#53(8.8.8.8) (UDP)
</code></pre>
<p><strong>What I found:</strong> I got 13 <code>.com</code> servers, <code>a.gtld-servers.net.</code> to <code>m.gtld-servers.net.</code>, with a TTL of <code>21600</code> (6 hours). They know who is responsible for every <code>.com</code> domain, but not what's inside any of them.</p>
<p>In the trace below, the same <code>.com</code> servers show a TTL of <code>172800</code>. When I asked <code>1.1.1.1</code> instead, it showed <code>164710</code>, so Google's resolver (<code>8.8.8.8</code>) seems to report a shorter TTL than the real servers. Numbers from a resolver can differ from what the real servers say.</p>
<hr />
<h2>Level 3: Ask the owner with <code>dig google.com NS</code></h2>
<p>Now we reach the owner. The authoritative name servers hold the real records for a domain, so they have the final word.</p>
<blockquote>
<p><strong>Real-life comparison:</strong> This is the exact house. The directories only told us the street, and here is the person who actually lives there.</p>
</blockquote>
<pre><code class="language-bash">dig google.com NS
</code></pre>
<pre><code class="language-plaintext">;; ANSWER SECTION:
google.com.  21600  IN  NS  ns3.google.com.
google.com.  21600  IN  NS  ns1.google.com.
google.com.  21600  IN  NS  ns4.google.com.
google.com.  21600  IN  NS  ns2.google.com.

;; SERVER: 8.8.8.8#53(8.8.8.8) (UDP)
</code></pre>
<p><strong>What I found:</strong> I got four servers, <code>ns1.google.com.</code> to <code>ns4.google.com.</code>, with a TTL of <code>21600</code>. These are the same four from part 1, where I found them with <code>nslookup</code>. Same answer, different tool.</p>
<p><strong>Why NS records matter:</strong> An NS record says who answers for a domain. If nobody answered, nobody could find google.com's records, so the site and email would be unreachable even if the servers were fine. That's also why Google lists four, so one failing doesn't break it.</p>
<hr />
<h2>Boss level: the full answer with <code>dig google.com</code></h2>
<p>The final move: ask for the actual address of <code>google.com</code>, its A record.</p>
<pre><code class="language-bash">dig google.com
</code></pre>
<pre><code class="language-plaintext">;; ANSWER SECTION:
google.com.  251  IN  A  142.251.106.113
google.com.  251  IN  A  142.251.106.100
google.com.  251  IN  A  142.251.106.102
google.com.  251  IN  A  142.251.106.139
google.com.  251  IN  A  142.251.106.138
google.com.  251  IN  A  142.251.106.101

;; SERVER: 8.8.8.8#53(8.8.8.8) (UDP)
</code></pre>
<p><strong>What I found:</strong> Six IPv4 addresses came back, so traffic can be shared across several servers. The TTL is <code>251</code> seconds. In the trace below, Google's own server says <code>300</code>, so my resolver was probably giving me a saved copy. When I ran the command again, I saw 109, 200 and 281 on different tries, so the number did not tick down in a straight line. Google's public resolver is probably many servers behind one address, and each try may reach a different saved copy. The addresses also weren't the same in every command (<code>142.251.106.x</code> here, <code>192.178.173.x</code> in the trace), so yours may differ.</p>
<p><strong>From dig to your browser:</strong> Your browser takes one of these addresses, connects to that server, and the server sends back the page. That's step 3 from part 1, now with real numbers.</p>
<img src="https://cdn.hashnode.com/uploads/covers/69b2730b6c896b0519049468/18176600-0df4-4a3d-8078-a6eebb5f13b0.png" alt="Diagram: step-by-step resolution flow for google.com" style="display:block;margin:0 auto" />

<hr />
<h2>Bonus: the real walk with <code>dig +trace</code></h2>
<p>The earlier commands went through my resolver. <code>dig +trace</code> skips that shortcut and asks each layer itself, starting from the root, so you can see the real walk. I added <code>+nodnssec</code> to hide the long security signature lines.</p>
<pre><code class="language-bash">dig +trace +nodnssec google.com
</code></pre>
<pre><code class="language-plaintext">.  87203  IN  NS  m.root-servers.net.
.  87203  IN  NS  l.root-servers.net.
.  87203  IN  NS  g.root-servers.net.
(... 10 more root servers ...)
;; Received 239 bytes from 8.8.8.8#53(8.8.8.8) in 68 ms

com.  172800  IN  NS  b.gtld-servers.net.
com.  172800  IN  NS  f.gtld-servers.net.
com.  172800  IN  NS  h.gtld-servers.net.
(... 10 more .com servers ...)
;; Received 863 bytes from 192.112.36.4#53(g.root-servers.net) in 292 ms

google.com.  172800  IN  NS  ns2.google.com.
google.com.  172800  IN  NS  ns1.google.com.
google.com.  172800  IN  NS  ns3.google.com.
google.com.  172800  IN  NS  ns4.google.com.
;; Received 287 bytes from 192.55.83.30#53(m.gtld-servers.net) in 168 ms

google.com.  300  IN  A  192.178.173.138
google.com.  300  IN  A  192.178.173.100
google.com.  300  IN  A  192.178.173.102
google.com.  300  IN  A  192.178.173.113
google.com.  300  IN  A  192.178.173.139
google.com.  300  IN  A  192.178.173.101
;; Received 135 bytes from 216.239.32.10#53(ns1.google.com) in 100 ms
</code></pre>
<p>I trimmed the lines about IPv6 failing ("network unreachable"), because my setup has no IPv6 route. <code>dig</code> then used IPv4 and finished normally. I also shortened the long server lists and tightened the spacing between columns.</p>
<p><strong>What I found:</strong> A different server answered at every step. My resolver (<code>8.8.8.8</code>) gave the list of root servers, <code>g.root-servers.net</code> pointed me to the <code>.com</code> servers, <code>m.gtld-servers.net</code> pointed me to Google's name servers, and finally <code>ns1.google.com</code> gave the A records. Each layer only knew who to ask next, and only the last one knew the answer. The TTLs change too: <code>172800</code> seconds (2 days) for the pointers, and <code>300</code> (5 minutes) for the final address.</p>
<p>I ran the same trace on <code>github.com</code>. It followed the same walk, but GitHub's name servers are spread across two providers (<code>awsdns</code> and <code>nsone.net</code>), and the final TTL was 60 seconds, not 300.</p>
<hr />
<h2>Your sidekick: the recursive resolver</h2>
<p>I typed one question, but several servers were involved. Who did the walking? A recursive resolver. It takes your question, asks the root, then <code>.com</code>, then the owner, and brings back the answer. It also remembers answers for a while (that's the TTL), so the next person who asks gets it faster.</p>
<blockquote>
<p><strong>Real-life comparison:</strong> Think of a sidekick in a game. You say "find the key", and they run through every level for you and come back with it.</p>
</blockquote>
<img src="https://cdn.hashnode.com/uploads/covers/69b2730b6c896b0519049468/9333c73e-690b-4bad-9128-73655e0c56f2.png" alt="Diagram: the resolver talking to root, TLD and authoritative servers" style="display:block;margin:0 auto" />

<p>When you press Enter in a browser, the same thing happens: the browser asks a resolver, the resolver walks through the levels, and the browser gets an IP address and connects.</p>
<hr />
<h2>Why this matters when you build things</h2>
<ul>
<li><p>Google has four name servers, so one can fail and the domain still works.</p>
</li>
<li><p>TTL decides roughly how fast changes spread. With a TTL of 5 minutes, most people see a change soon. With 2 days, some keep seeing the old answer for a long time.</p>
</li>
<li><p>If DNS fails, your app is unreachable even when your server is fine.</p>
</li>
</ul>
<hr />
<h2>Cheat sheet: which command is which level?</h2>
<table>
<thead>
<tr>
<th>Command</th>
<th>Level</th>
<th>Who answers</th>
<th>What I learned</th>
</tr>
</thead>
<tbody><tr>
<td><code>dig . NS</code></td>
<td>1</td>
<td>My resolver (<code>8.8.8.8</code>)</td>
<td>The 13 root servers</td>
</tr>
<tr>
<td><code>dig com NS</code></td>
<td>2</td>
<td>My resolver</td>
<td>The 13 <code>.com</code> servers</td>
</tr>
<tr>
<td><code>dig google.com NS</code></td>
<td>3</td>
<td>My resolver</td>
<td>Google's 4 name servers</td>
</tr>
<tr>
<td><code>dig google.com</code></td>
<td>Boss</td>
<td>My resolver</td>
<td>6 IPv4 addresses</td>
</tr>
<tr>
<td><code>dig +trace +nodnssec google.com</code></td>
<td>Bonus</td>
<td>Root, <code>.com</code>, then Google's own server</td>
<td>Each layer only points to the next</td>
</tr>
</tbody></table>
<img src="https://cdn.hashnode.com/uploads/covers/69b2730b6c896b0519049468/35de3438-94c3-4fe0-ab39-4a5f7fb3ba78.png" alt="Diagram: dig commands mapped to the levels" style="display:block;margin:0 auto" />

<hr />
<h2>Play it yourself</h2>
<p>Pick any domain and run the same commands. Look at how many answers you get, the TTL numbers, and the <code>Received ... from ...</code> lines in the trace. For a <code>.org</code> domain, ask <code>dig org NS</code> for Level 2.</p>
<pre><code class="language-bash">dig . NS
dig com NS
dig google.com NS
dig google.com
dig +trace +nodnssec google.com
</code></pre>
<hr />
<h2>Quest complete: recap</h2>
<table>
<thead>
<tr>
<th>Stage</th>
<th>Who they are</th>
<th>What they know</th>
<th>Real-life comparison</th>
</tr>
</thead>
<tbody><tr>
<td>Root</td>
<td>13 servers, <code>a</code> to <code>m</code></td>
<td>Who handles <code>.com</code></td>
<td>Country directory</td>
</tr>
<tr>
<td>TLD</td>
<td>13 <code>.com</code> servers</td>
<td>Who handles each <code>.com</code> domain</td>
<td>City directory</td>
</tr>
<tr>
<td>Authoritative</td>
<td><code>ns1</code> to <code>ns4.google.com</code></td>
<td>The real records</td>
<td>The exact house</td>
</tr>
<tr>
<td>Resolver</td>
<td><code>8.8.8.8</code> here</td>
<td>Asks the layers and remembers the answers</td>
<td>Your sidekick</td>
</tr>
</tbody></table>
<hr />
<h2>Final thoughts</h2>
<p>What surprised me most is how little each layer knows. In my first four commands I only talked to a resolver, and with <code>dig +trace</code> I finally talked to the real servers. The root, <code>.com</code> and Google's servers each pointed me to the next one, and only the last one knew the answer. Once I saw that, DNS stopped feeling like magic.</p>
<p>In the next post, I'll explore cURL: how to make HTTP requests, inspect responses, and test APIs directly from the terminal.</p>
<p>Which level surprised you the most? Tell me in the comments.</p>
]]></content:encoded></item><item><title><![CDATA[How does a browser know where a website lives?]]></title><description><![CDATA[You type google.com, press Enter, and a moment later the page appears on your screen. But your browser has no idea where that website lives. So how does it find the right computer out of billions?
I'm]]></description><link>https://thetejascodes.hashnode.dev/how-does-a-browser-know-where-a-website-lives</link><guid isPermaLink="true">https://thetejascodes.hashnode.dev/how-does-a-browser-know-where-a-website-lives</guid><category><![CDATA[dns]]></category><category><![CDATA[networking]]></category><category><![CDATA[Beginner Developers]]></category><category><![CDATA[webdev]]></category><category><![CDATA[ChaiCode]]></category><category><![CDATA[Chaiaurcode]]></category><category><![CDATA[chaicode webdev cohort 2026]]></category><dc:creator><![CDATA[Tejas Kishan Kale]]></dc:creator><pubDate>Thu, 08 Oct 2026 08:01:29 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/69b2730b6c896b0519049468/0319dea6-a8e4-486e-bfc1-a5b4c44429e6.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>You type <code>google.com</code>, press Enter, and a moment later the page appears on your screen. But your browser has no idea where that website lives. So how does it find the right computer out of billions?</p>
<p>I'm learning full-stack development, and I recently started learning DNS. In this post, I'll share what I learned about DNS and its records (NS, A, AAAA, CNAME, MX, and TXT). I'll use simple language and real-life examples, so if you're a beginner, this is for you.</p>
<hr />
<h2>What is DNS?</h2>
<p>Without DNS, you would have to type a number like <code>142.250.195.46</code> in your browser instead of a name. This number is called an IP address, and computers use it as a unique identity to communicate with each other. But people can't remember these numbers. Imagine memorizing a different number for every website you visit.</p>
<blockquote>
<p>Now think about calling your best friend. You don't type "their number", you just search "their name" in your phonebook and call. DNS works the same way: it is the phonebook of the internet. You type the name, and DNS finds the number for you.</p>
</blockquote>
<img src="https://cdn.hashnode.com/uploads/covers/69b2730b6c896b0519049468/1b81ddb1-c00c-40ff-b485-11bd1c4cf8cd.png" alt="Diagram 1: Browser → DNS → Server" style="display:block;margin:0 auto" />

<ol>
<li><p>You type <code>google.com</code> and press Enter. Your browser asks DNS where this website lives.</p>
</li>
<li><p>DNS converts the domain name into an IP address and gives it back to your browser.</p>
</li>
<li><p>Your browser uses that IP address to reach the server, and the server sends the website's files to your screen.</p>
</li>
</ol>
<p>There are a few more steps behind the scenes, which I'll cover in part 2.</p>
<hr />
<h2>Why do we need DNS records?</h2>
<p>A domain like <code>google.com</code> has to answer more than one question. Where is the website? Where should emails go? Who manages this domain? Is it really owned by the person who claims it?</p>
<p>One answer can't cover all of these, so each answer is stored separately in the domain's DNS settings. Each entry is called a <strong>DNS record</strong>. A DNS record is one instruction that tells the internet one specific thing about your domain.</p>
<p>Think of a contact card on your phone. It holds a home address, a mobile number, and an email, each as its own entry. A domain works the same way, and each DNS record is one entry on its card.</p>
<p>Let's go through the records one at a time.</p>
<hr />
<h2>NS Record</h2>
<p>Before anyone can ask where your website lives, they need to know who to ask. That is what the <strong>NS (Name Server) record</strong> does. It tells the internet which servers are responsible for answering questions about your domain.</p>
<p>Most domains have two or more NS records, so if one server is down, another can still answer.</p>
<blockquote>
<p><strong>Real-life comparison:</strong> Think of the local post office in charge of your area. When a letter needs to reach your neighborhood, everyone knows which post office handles it. An NS record points to the "post office" for your domain.</p>
</blockquote>
<p>Here is the real output I got by running <code>nslookup -type=NS google.com</code> in my terminal:</p>
<pre><code class="language-plaintext">google.com      nameserver = ns1.google.com
google.com      nameserver = ns2.google.com
google.com      nameserver = ns3.google.com
google.com      nameserver = ns4.google.com
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/69b2730b6c896b0519049468/7e01b610-e086-4de0-97bb-c7937e7a2010.png" alt="Diagram 5: DNS hierarchy" style="display:block;margin:0 auto" />

<p>Root servers and .com servers are the first steps DNS takes to find a domain's name servers. I'll explain how that works in part 2.</p>
<hr />
<h2>A Record</h2>
<p>An A record solves the problem of connecting a domain name like <code>google.com</code> to an IPv4 address that computers use to communicate.</p>
<blockquote>
<p><strong>Real-life comparison:</strong> An A record is like a house address. You know the house by its name, but you need its address to find it.</p>
</blockquote>
<p>Here is the real output I got by running <code>nslookup -type=A google.com</code> in my terminal:</p>
<pre><code class="language-plaintext">google.com      142.250.122.102
google.com      142.250.122.101
google.com      142.250.122.138
google.com      142.250.122.100
google.com      142.250.122.139
google.com      142.250.122.113
</code></pre>
<p>Big sites like Google have many IPv4 addresses, so traffic can be shared across several servers.</p>
<img src="https://cdn.hashnode.com/uploads/covers/69b2730b6c896b0519049468/aec80704-dbc9-4013-afd1-1fd6c5130751.png" alt="Diagram 2: Domain → IPv4" style="display:block;margin:0 auto" />

<hr />
<h2>AAAA Record</h2>
<p>IPv4 addresses like <code>142.250.122.102</code> worked well for a long time, but there are only about 4 billion of them. With phones, laptops, smartwatches, and smart TVs all online, the world started running out.</p>
<p>The fix is <strong>IPv6</strong>, a newer address format with a practically unlimited supply. An IPv6 address is much longer, something like <code>2404:6800:4013:802::71</code>. The <strong>AAAA record</strong> (say "quad-A") does the same job as the A record, but for IPv6: it connects a domain name to an IPv6 address.</p>
<blockquote>
<p><strong>Real-life comparison:</strong> Think of a contact on your phone who now has two numbers, an old short one and a new longer one. It's the same person, and you can reach them on either. The A record is the old number, and the AAAA record is the new one.</p>
</blockquote>
<p>Here is the real output I got by running <code>nslookup -type=AAAA google.com</code> in my terminal:</p>
<pre><code class="language-plaintext">Name:    google.com
Addresses:  2404:6800:4013:802::71
          2404:6800:4013:802::8a
          2404:6800:4013:802::8b
          2404:6800:4013:802::65
</code></pre>
<p>Notice how much longer the address is compared to the IPv4 ones above. Most websites keep both an A and an AAAA record, so visitors on either type of network can reach them.</p>
<img src="https://cdn.hashnode.com/uploads/covers/69b2730b6c896b0519049468/df3cab80-6845-47be-b3b3-8fa5d8777578.png" alt="Diagram 2 extended: Domain → IPv4 and IPv6" style="display:block;margin:0 auto" />

<hr />
<h2>CNAME Record</h2>
<p>Sometimes you don't want to point a name at a number. You want to point it at <strong>another name</strong>. For example, <code>www.example.com</code> and <code>example.com</code> should open the same website. Instead of repeating the IP address in two places, a <strong>CNAME (Canonical Name) record</strong> says: "this name is just another name for that one."</p>
<blockquote>
<p><strong>Real-life comparison:</strong> Think of a nickname. Friends call someone "Bunty", but their real name is Rahul. If you ask for Bunty's number, you end up looking up Rahul's contact. A CNAME works the same way: it sends you to the real name, and the real name gives the answer.</p>
</blockquote>
<p>Here is how a CNAME record looks (this is an example, not real output):</p>
<pre><code class="language-plaintext">www.example.com.   CNAME   example.com.
</code></pre>
<p>This says: "<code>www.example.com</code> is another name for <code>example.com</code>. Wherever that goes, I go too."</p>
<img src="https://cdn.hashnode.com/uploads/covers/69b2730b6c896b0519049468/a7033f29-e5f2-49ff-92d1-da21e3b1fbdd.png" alt="Diagram 3: CNAME → another name → IP" style="display:block;margin:0 auto" />

<h3>Why use a name instead of an IP?</h3>
<p>If your server's IP address changes, you update <strong>one</strong> A record, and every CNAME pointing to that name follows automatically. It's also how many services work. Platforms like Hashnode or GitHub Pages often give you a <em>name</em> to point your subdomain (like <code>www</code>) to, not a fixed IP.</p>
<h3>A vs CNAME</h3>
<table>
<thead>
<tr>
<th></th>
<th>A Record</th>
<th>CNAME Record</th>
</tr>
</thead>
<tbody><tr>
<td>Points to</td>
<td>An <strong>IP address</strong> (a number)</td>
<td><strong>Another domain name</strong></td>
</tr>
<tr>
<td>Example</td>
<td><code>example.com → 203.0.113.10</code></td>
<td><code>www.example.com → example.com</code></td>
</tr>
<tr>
<td>Real-life</td>
<td>"Here's the house address"</td>
<td>"Same person, different nickname"</td>
</tr>
</tbody></table>
<p><strong>Rule of thumb:</strong> if you have an IP address, use <strong>A</strong>. If you have a name, use <strong>CNAME</strong>.</p>
<p>One catch: a CNAME usually can't be used on the bare domain (<code>example.com</code>), only on names like <code>www</code>.</p>
<hr />
<h2>MX Record</h2>
<p>Your website and your email are two separate things, and they often live on different servers. So when someone sends an email to <code>hello@example.com</code>, how does their email system know where to deliver it? That's what the <strong>MX (Mail Exchange) record</strong> is for. It tells the world which mail server receives email for your domain.</p>
<blockquote>
<p><strong>Real-life comparison:</strong> Think of an apartment building. Visitors use the main gate (the A record), but couriers and letters go straight to the mailroom. The MX record tells everyone where the mailroom is.</p>
</blockquote>
<p>Here is the real output I got by running <code>nslookup -type=MX google.com</code> in my terminal:</p>
<pre><code class="language-plaintext">google.com      MX preference = 10, mail exchanger = smtp.google.com
</code></pre>
<p>This line has a <strong>priority number</strong> (10) and a mail server name (<code>smtp.google.com</code>). The <strong>lower number is tried first</strong>. Many domains list two or more mail servers with different numbers, so if the first one is down, email falls back to the next one. Google uses just one here, but it is a big setup behind that single name.</p>
<img src="https://cdn.hashnode.com/uploads/covers/69b2730b6c896b0519049468/71a98780-6365-4834-b116-0b0369de822b.png" alt="Diagram 4: Email routing" style="display:block;margin:0 auto" />

<p>The diagram uses a typical setup with two mail servers. Google's real output above has one.</p>
<h3>NS vs MX</h3>
<p>At first, these two looked the same to me, because both are "server records". Here is how I separate them:</p>
<ul>
<li><p><strong>NS</strong> answers: <em>"Who manages the DNS records for this domain?"</em> It's the <strong>post office in charge of the area</strong>.</p>
</li>
<li><p><strong>MX</strong> answers: <em>"Where should this domain's email be delivered?"</em> It's the <strong>mailroom</strong> for your letters.</p>
</li>
</ul>
<p>NS tells you <em>who to ask</em>. MX is <em>one of the answers</em> they give.</p>
<hr />
<h2>TXT Record</h2>
<p>The <strong>TXT (Text) record</strong> is a notes field. It doesn't send visitors or emails anywhere. It just <em>says something</em> about your domain, and other services read it. You'll mostly see it in two places:</p>
<ul>
<li><p><strong>Domain verification.</strong> Services like Google ask you to add a specific text value to prove you own the domain.</p>
</li>
<li><p><strong>Email security.</strong> Records like <strong>SPF</strong> list which servers are allowed to send email on behalf of your domain, which helps stop people from faking emails from it.</p>
</li>
</ul>
<blockquote>
<p><strong>Real-life comparison:</strong> Think of a notice on the gate of a housing society. It doesn't change where anyone goes, but it tells you something about the place. An SPF record is like a guest list at that gate: only the names on the list are allowed in.</p>
</blockquote>
<p>Here is the real output I got by running <code>nslookup -type=TXT google.com</code> in my terminal. Google has 17 TXT records, so I'm showing just four:</p>
<pre><code class="language-plaintext">google.com      text =

        "v=spf1 include:_spf.google.com ~all"
google.com      text =

        "google-site-verification=TV9-DBe4R80X4v0M4U_bd_J9cpOJM0nikft0jAgjmsQ"
google.com      text =

        "facebook-domain-verification=22rm551cu4k0ab0bxsw536tlds4h95"
google.com      text =

        "apple-domain-verification=30afIBcvSuDV2PLX"
</code></pre>
<p>The first line is an <strong>SPF record</strong>. It says only Google's own mail servers (<code>_spf.google.com</code>) are allowed to send email for <code>google.com</code>. The other three are <strong>verification records</strong>: Google, Facebook, and Apple each asked for a specific text value to confirm that this domain belongs to the same owner.</p>
<p>A domain can have many TXT records, because every service you connect adds its own note. That's why the full output looked so messy to me at first.</p>
<hr />
<h2>How all records work together</h2>
<p>Remember the contact card from earlier? Here is the full card for a small website, <code>example.com</code>. Each row is one entry, and each entry answers one question.</p>
<table>
<thead>
<tr>
<th>Type</th>
<th>Name</th>
<th>Value</th>
<th>What it does</th>
</tr>
</thead>
<tbody><tr>
<td><strong>NS</strong></td>
<td><code>example.com</code></td>
<td><code>ns1.mydnsprovider.com</code></td>
<td>Says who manages this domain's DNS</td>
</tr>
<tr>
<td><strong>A</strong></td>
<td><code>example.com</code></td>
<td><code>203.0.113.10</code></td>
<td>Sends visitors to the web server (IPv4)</td>
</tr>
<tr>
<td><strong>AAAA</strong></td>
<td><code>example.com</code></td>
<td><code>2001:db8::10</code></td>
<td>Same, for IPv6 visitors</td>
</tr>
<tr>
<td><strong>CNAME</strong></td>
<td><code>www</code></td>
<td><code>example.com</code></td>
<td>Makes <code>www</code> work like the main site</td>
</tr>
<tr>
<td><strong>MX</strong></td>
<td><code>example.com</code></td>
<td><code>10 mail1.emailprovider.com</code></td>
<td>Delivers email to your mail provider</td>
</tr>
<tr>
<td><strong>TXT</strong></td>
<td><code>example.com</code></td>
<td><code>v=spf1 include:_spf.emailprovider.com ~all</code></td>
<td>Verifies the domain and protects email</td>
</tr>
</tbody></table>
<img src="https://cdn.hashnode.com/uploads/covers/69b2730b6c896b0519049468/46478c45-f71b-4ae3-9a43-b298b6564103.png" alt="Diagram 6: Complete DNS setup for a small website" style="display:block;margin:0 auto" />

<p>Here is what happens in real life, using the same records:</p>
<ol>
<li><p><strong>A visitor opens your site.</strong> The NS records tell DNS who to ask. The A or AAAA record gives the server's address. If the visitor typed <code>www.example.com</code>, the CNAME sends the lookup to the main name first. Then the browser connects to the server and loads the page.</p>
</li>
<li><p><strong>Someone emails you.</strong> Their mail system looks up your MX record and delivers the message to your mail provider.</p>
</li>
<li><p><strong>Gmail receives a message that claims to be from you.</strong> It checks your TXT record (SPF) to see if the sender is allowed.</p>
</li>
</ol>
<p>Same domain, different questions, different records. Once I saw it this way, the DNS settings page stopped looking scary.</p>
<hr />
<h2>Try it yourself</h2>
<p>You can look up all of these records yourself. Open your terminal and run:</p>
<pre><code class="language-bash">nslookup -type=NS google.com
nslookup -type=A google.com
nslookup -type=AAAA google.com
nslookup -type=MX google.com
nslookup -type=TXT google.com
</code></pre>
<p>On Mac or Linux you can also use <code>dig google.com MX</code>. Try it on your own domain or a site you like.</p>
<p>Here is what I found for <code>google.com</code>:</p>
<table>
<thead>
<tr>
<th>Record</th>
<th>What I got</th>
</tr>
</thead>
<tbody><tr>
<td>NS</td>
<td>4 name servers (<code>ns1</code> to <code>ns4.google.com</code>)</td>
</tr>
<tr>
<td>A</td>
<td>6 IPv4 addresses</td>
</tr>
<tr>
<td>AAAA</td>
<td>4 IPv6 addresses</td>
</tr>
<tr>
<td>MX</td>
<td>1 mail server, priority 10 (<code>smtp.google.com</code>)</td>
</tr>
<tr>
<td>TXT</td>
<td>17 notes, mostly verification, plus 1 SPF</td>
</tr>
</tbody></table>
<p>You can spot each record by one keyword in the output:</p>
<table>
<thead>
<tr>
<th>If you see this</th>
<th>It's this record</th>
</tr>
</thead>
<tbody><tr>
<td><code>nameserver =</code></td>
<td>NS</td>
</tr>
<tr>
<td>An address like <code>142.250.122.102</code></td>
<td>A (IPv4)</td>
</tr>
<tr>
<td>A long address with colons</td>
<td>AAAA (IPv6)</td>
</tr>
<tr>
<td><code>mail exchanger =</code></td>
<td>MX</td>
</tr>
<tr>
<td><code>text =</code></td>
<td>TXT</td>
</tr>
</tbody></table>
<hr />
<h2>Recap</h2>
<table>
<thead>
<tr>
<th>Record</th>
<th>One-line meaning</th>
<th>Real-life comparison</th>
</tr>
</thead>
<tbody><tr>
<td><strong>NS</strong></td>
<td>Who is in charge of this domain</td>
<td>Local post office</td>
</tr>
<tr>
<td><strong>A</strong></td>
<td>Name → IPv4 address</td>
<td>House address</td>
</tr>
<tr>
<td><strong>AAAA</strong></td>
<td>Name → IPv6 address</td>
<td>Same contact, new longer number</td>
</tr>
<tr>
<td><strong>CNAME</strong></td>
<td>Name → another name</td>
<td>Nickname</td>
</tr>
<tr>
<td><strong>MX</strong></td>
<td>Where email is delivered</td>
<td>Apartment mailroom</td>
</tr>
<tr>
<td><strong>TXT</strong></td>
<td>Notes and verification</td>
<td>Notice on the society gate</td>
</tr>
</tbody></table>
<hr />
<h2>Final thoughts</h2>
<p>So, how does a browser know where a website lives? It asks DNS. DNS finds the right name servers (NS), then reads the answer from the right record: A, AAAA or CNAME for the website, MX for email, and TXT for verification.</p>
<p>DNS looked scary to me at first, with all those acronyms. But each record is just one small answer to one small question. Once you know the question, the record makes sense.</p>
<p>I'm learning full-stack development, so my next post goes one level deeper: how DNS resolution works, from root servers to the final answer, using <code>dig</code>.</p>
<p>Which record confused you the most? Tell me in the comments, and I'll try to explain it better.</p>
]]></content:encoded></item><item><title><![CDATA[I Was Using HTTP Status Codes Wrong — Here’s My Safari Through Real API Responses]]></title><description><![CDATA[When I started building backend APIs, I didn’t think much about HTTP status codes. If the API worked, I returned 200 OK. If something failed, I returned 500. That was my entire system. And honestly, I]]></description><link>https://thetejascodes.hashnode.dev/i-was-using-http-status-codes-wrong-here-s-my-safari-through-real-api-responses</link><guid isPermaLink="true">https://thetejascodes.hashnode.dev/i-was-using-http-status-codes-wrong-here-s-my-safari-through-real-api-responses</guid><dc:creator><![CDATA[Tejas Kishan Kale]]></dc:creator><pubDate>Wed, 18 Mar 2026 05:14:51 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/69b2730b6c896b0519049468/d6d4489b-88a0-47c4-b515-9e996df3e305.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<hr />
<p>When I started building backend APIs, I didn’t think much about HTTP status codes. If the API worked, I returned 200 OK. If something failed, I returned 500. That was my entire system. And honestly, I thought it was fine. But while working on my workspace project, I started noticing something—my APIs were working, but they didn’t feel right. That’s when I went deeper into HTTP status codes… and realized I was doing it wrong.</p>
<h3><mark class="bg-yellow-200 dark:bg-yellow-500/30">🔹The “200 for Everything” Phase</mark></h3>
<blockquote>
<p>At the beginning, every response looked like this:</p>
</blockquote>
<pre><code class="language-typescript">res.status(200).json({ message: "Something happened" });
</code></pre>
<blockquote>
<p>Delete? → 200<br />Error? → 200<br />Not found? → 200</p>
<p>It worked… but it had no meaning.</p>
</blockquote>
<blockquote>
<p>I wasn’t communicating with the frontend properly—I was just sending responses.</p>
<hr />
</blockquote>
<h3><mark class="bg-yellow-200 dark:bg-yellow-500/30">🔹 The First Realization</mark></h3>
<blockquote>
<p>The first time things clicked was when I learned about <code>404 Not Found</code>.</p>
<p>Instead of sending a success response for everything, I started thinking:</p>
<p>“What if the resource actually doesn’t exist?”</p>
</blockquote>
<pre><code class="language-typescript">if (!workspace) { 
 return res.status(404).json({message: "Workspace not found"});
}
</code></pre>
<blockquote>
<p>That small change made my API feel more “real”.</p>
</blockquote>
<hr />
<h3><mark class="bg-yellow-200 dark:bg-yellow-500/30">🔹 The 204 Moment</mark></h3>
<blockquote>
<p>Then came the biggest shift—DELETE APIs.</p>
<p>Earlier, I used to write:</p>
</blockquote>
<pre><code class="language-typescript">res.status(200).json({ message: "Deleted successfully" });
</code></pre>
<blockquote>
<p>But then I learned about <code>204 No Content</code>.</p>
<p>It made me think:</p>
<p>“If the resource is deleted… why am I sending anything back?”</p>
</blockquote>
<pre><code class="language-typescript">res.status(204).send();
</code></pre>
<blockquote>
<p>That moment changed how I think about APIs.</p>
<h3>It wasn’t just about making things work anymore—it was about making them <strong>correct</strong>.</h3>
</blockquote>
<hr />
<h3><mark class="bg-yellow-200 dark:bg-yellow-500/30">🔹 Confusion: 401 vs 403</mark></h3>
<blockquote>
<p>Another thing that confused me a lot was <code>401</code> vs <code>403</code>.</p>
<p>I used them randomly at first.</p>
</blockquote>
<p>Then realization:</p>
<blockquote>
<p>But later I understood:</p>
</blockquote>
<ul>
<li><p>401 → User is not logged in</p>
</li>
<li><p>403 → User is logged in but not allowed</p>
</li>
</ul>
<blockquote>
<p>That distinction helped me design better authentication logic.</p>
</blockquote>
<hr />
<h3><mark class="bg-yellow-200 dark:bg-yellow-500/30">🔹 My Current Approach</mark></h3>
<blockquote>
<p>Now, whenever I write an API, I don’t just think:</p>
<p>“Does it work?”</p>
<p>I think:</p>
<p>“Is this the correct response?”</p>
</blockquote>
<blockquote>
<p>”</p>
</blockquote>
<p>👉 mindset shift:</p>
<ul>
<li><p>200 → Data returned</p>
</li>
<li><p>201 → Resource created</p>
</li>
<li><p>204 → No content needed</p>
</li>
<li><p>4xx → Client mistake</p>
</li>
<li><p>5xx → My mistake</p>
</li>
</ul>
<hr />
<h3><mark class="bg-yellow-200 dark:bg-yellow-500/30">🔹 What I Learned</mark></h3>
<blockquote>
<p>This journey taught me something important:</p>
<p>Backend development is not just about logic—it’s about <strong>communication</strong>.</p>
<p>HTTP status codes are the language your API uses to talk to the client.</p>
</blockquote>
<hr />
<h3><mark class="bg-yellow-200 dark:bg-yellow-500/30">🔹 Final Thoughts</mark></h3>
<blockquote>
<p>I’m still learning, still making mistakes.</p>
<p>But small improvements like using the right status codes make a huge difference.</p>
<p>From “just making APIs work” → to “building clean and meaningful APIs”</p>
<p>That’s been my real progress.</p>
</blockquote>
<hr />
<h2><strong>📢 CTA</strong></h2>
<blockquote>
<p>If you’re learning backend like me, don’t ignore these small details—they matter more than you think.</p>
<p>Let’s keep improving 🚀</p>
</blockquote>
]]></content:encoded></item></channel></rss>