Introduction: How Does a Browser Know Where a Website Lives?
When you type google.com into your browser, something interesting happens behind the scenes.
Your browser doesn’t magically know where Google lives on the internet. It doesn’t even understand names like google.com at all.
What it understands are numbers—IP addresses like 142.250.190.14. So the real question becomes:
How does a human-friendly name turn into a machine-friendly address?
All these translation job is handled by DNS.
What is this DNS?
The Domain Name System (DNS) is the phonebook of the Internet. What happens in phonebook? By this you remember people by names, phones connect using numbers. Humans access information online through domain names, like google.com or chaicode.com. Web browsers interact through Internet Protocol (IP) addresses. DNS translates domain names (example.com) to IP addresses (ex: 93.184.216.34) so browsers can load Internet resources.
DNS works using the distributed hierarchical structure of servers.
Now the question is:
How does it actually work in our fingertips??
Let's find out this in our next section.
How does DNS work?
The DNS query can be broken down into several steps, ensuring that users can access websites by simply typing a domain name into their browser. The DNS resolution works recursively.
The main motto of DNS is:
Who should I talk to next?
Everything in DNS is working based on this question. You are going to findout soon.
-
User Input: You enter a website address (for example,
chaicode.com) into your web browser's address bar. - Local Cache Check: Your browser first checks its local cache to see if it has recently looked up the domain. It gets stored due to the DNS caching; DNS caching is a mechanism that stores DNS records locally to avoid querying external DNS servers repeatedly for the same information. This speeds up the browsing experience and reduces network traffic. If it finds the corresponding IP address, it uses that directly without querying external servers. And if it doesn't find it then it will move to the next step.
- DNS Resolver Query: If the IP address isn’t in the local cache, your browser sends the request to the DNS resolver. The resolver is typically provided by your Internet Service Provider (ISP) or by your Router.
-
Root DNS Server: The DNS resolver sends the request to a root DNS server. There are in total 13 root Name Server around the world, but thanks to Anycast IP Addressing, which allows multiple physical severs to share the same IP, the total instances of Root Servers are more than 1700. The root server doesn’t know the exact IP address for
chaicode.combut knows which Top-Level Domain (TLD) server to query based on the domain’s extension. -
TLD Server: TLD stands for Top-Level-Domain, these servers manage domain extensions like .com, .org, .net, .edu, .gov and others. The TLD server for .com directs the resolver to the authoritative DNS server for
chaicode.com. - Authoritative DNS Server: This server holds the actual DNS records for chaicode.com, including the IP address of the website’s server. There are many popular Authoritative DNS Servers around the world like: Cloudflare, Vercel, Netlify, Digital Ocean, Hostinger, Namecheap, Godaddy etc. It sends this IP address back to the resolver.
- Final Response: The DNS resolver sends the IP address to your browser, allowing it to connect to the website’s server and load the page. Besides that for future reference, the IP address gets stored in the local cache.
So here we can see that every server is actually telling the DNS resolver that who should it talk to next to get more information. That's why the resolver is often referred as Recursive DNS Resolver.
If this feels like overwhelming, that’s okay. The key idea to remember is simple: DNS keeps asking the next right server until it finds the final answer.
What and Why the DNS Records
DNS records (aka zone files) are instructions that live in authoritative DNS servers and provide information about a domain including what IP address is associated with that domain and how to handle requests for that domain. These records consist of a series of text files written in what is known as DNS syntax. DNS syntax is just a string of characters used as commands that tell the DNS server what to do. All DNS records also have a ‘TTL’, which stands for time-to-live, which means how long a DNS record is cached before it expires. When the TTL expires, the cache is cleared and a fresh DNS query must be made.
But before diving into individual DNS records, let’s look at how they all work together for a single website.
Most common types of DNS records
DNS management relies on DNS server connections. Knowing how your DNS servers interact with each other via DNS records will make managing your DNS a less daunting task.
The most common types of DNS records are:
A Record
Address records, or A records, are the most common DNS records used. They create a direct connection between an IPv4 address and a domain name. IPv4 addresses have the following format: 93.184.216.34. This is the simplest record and this is the last cycle of a DNS query means the resolver looks for this record as its target. A record solves one simple problem: once DNS is done asking questions, this is the final answer it needs to reach the website. This is the most important IP also, because depending on this all the traffics would be sent to the server's machine. Example:
| Domain | Record | Value | TTL |
|---|---|---|---|
| example.com | A | 192.0.2.1 | 14400 |
AAAA Record
Same job as A records, but this type of record connects domain names to IPv6 addresses (8 groups of 4 hexadecimal digits). IPv6 addresses have more numerals than IPv4 address and are becoming more common as options for IPv4 addresses are running out. Example:
| Domain | Record | Value | TTL |
|---|---|---|---|
| @ | AAAA | 2606:2800:220:1:248:1893:25c8:1946 | 14400 |
The "@" symbol in this example indicates that this is a record for the root domain.
CNAME Record
Canonical name records, or CNAME records, direct an alias domain to a canonical domain. This means that the CNAME record stores another domain and the A record of that domain would be the value of the former. This type of record is used to link subdomains to domain A or AAAA records. It answers the question:
“This name is just an alias—what is the real name?”
For example, instead of creating two A records for www.example.com and product.example.com, you could link product.example.com & www.example.com to a CNAME record that is then linked to an A record for example.com. The value is that if the IP address changes for the root domain, only the A record will have to be updated and the CNAME will update accordingly.
For example:
| Record | Host | Value | TTL |
|---|---|---|---|
| CNAME | blog.piyushgarg.dev | hashnode.network | 10400 |
| A | hashnode.network | 76.76.21.21 | 10400 |
NS Record
The most important DNS record from the list. Nameserver, or NS records, show which DNS server is responsible for managing the DNS Queries and acting as the authoritative nameserver for your domain. Authoritative nameservers contain the final information about a specific domain and its corresponding IP address. An NS record points to all of the different records your domain holds. A domain often has multiple NS records which can indicate primary and secondary nameservers for that domain. Without NS records, users will not be able to access your website.
By querying the NS record value, we will get the A record of a DNS server i.e, an IP of that DNS server which is storing our needed website details and after querying that server's IP we will get the IP address of the desired website.
NS records don’t point to your website. They point to the DNS servers that know the answers about your website.
Here is an example of an NS record:
| example.com | Record | Value | TTL |
|---|---|---|---|
| @ | NS | pns1.exampleserver.com | 20400 |
Note that NS records can never point to a canonical name (CNAME) record.
MX Record
The Mail Exchanger record is used for email. This simply points to the server where the emails should be delivered for that domain name. These records, along with an email server, allow for the creation of individual email accounts, such as user@example.com, that are linked to the domain (example.com) and it should be running on SMTP. The Mail Transfer Agent will query the MX record for that domain and will look for the email server, and then DNS will respond with the server details with whom the MTA should send the email.
There are in general two email servers are used with different priorities. The 'priority' numbers before the domains for the MX records indicate preference; the lower 'priority' value is preferred. The server will always try mailhost1 first because 10 is lower than 20. In the result of a message send failure, the server will default to mailhost2.
| example.com | Record | Priority | Value | TTL |
|---|---|---|---|---|
| @ | MX | 10 | mailhost1.example.com | 40400 |
| @ | MX | 20 | mailhost2.example.com | 40400 |
TXT Record
Text, or TXT records, store miscellaneous textual information related to domains and subdomains. The TXT record was originally intended as a place for human-readable notes. However, now it is also possible to put some machine-readable data into TXT records. One domain can have many TXT records.
Spammers often try to fake or forge the domains from which they send their email messages. TXT records are a key component of several different email authentication methods (Like: SPF, DKIM, DMARC) that help an email server determine if a message is from a trusted source. By configuring these records, domain operators can make it more difficult for spammers to spoof their domains and can track attempts to do so.
SPF records: SPF TXT records list all the servers that are authorized to send email messages from a domain.
DKIM records: DKIM works with digital signature - each email using a public-private key pair. This helps verify that the email is actually from the domain it claims to be from.
DMARC records: A DMARC TXT record references the domain's SPF and DKIM policies.
Conclusion: DNS Is a System, Not a Set of Memorized Records
At first glance, DNS can feel overwhelming—root servers, name servers, records with strange names, and numbers everywhere. But once you step back, a simple pattern emerges.
DNS is not magic.
DNS is a question-and-answer system.
Each DNS record exists to solve one specific problem:
- NS records answer who is responsible for this domain
- A and AAAA records answer where the website lives
- CNAME records answer is this name just an alias
- MX records answer where emails should be delivered
- TXT records answer how this domain can prove or describe itself
Together, these records form a complete identity for a domain on the internet.
So the next time you type a website into your browser, remember: your browser isn’t guessing. It’s calmly asking the internet the right questions, in the right order, until it gets a clear, final answer.
And now—you know exactly how that happens.
Follow for more beginner-friendly breakdowns of core software engineering concepts.





Top comments (0)