DEV Community

Vigneshkumar Selvaraj
Vigneshkumar Selvaraj

Posted on Edited on

DNS Explained for Beginners: How Does the Internet Find a Website?

Have you ever wondered what happens when you type www.google.com into your browser and press Enter?

Within seconds, Google's homepage appears on your screen. But how does your computer know where Google is hosted? How does it find the correct server among millions of servers connected to the internet?

The answer is DNS (Domain Name System).

I recently started exploring DNS as part of my AWS Cloud Quest learning journey. Initially, concepts like Root Nameservers, TLD Nameservers, Authoritative Nameservers, and DNS Resolvers were a little confusing.

So, I decided to explain DNS in simple words, using real-world examples.

If you are new to AWS, cloud computing, or networking, this article is for you!

1. What is DNS?

DNS stands for Domain Name System.

In simple terms, DNS translates human-readable domain names into IP addresses that computers use to communicate with each other.

Let's understand this with an example.

Imagine you want to call your friend Rahul.

You don't remember his phone number, but you remember his name. You open your phone contacts, search for Rahul, find his phone number, and make the call.

DNS works in a similar way.

For example:

  • Domain name: www.google.com
  • IP address: 142.250.183.68 (example IP address)

Humans find domain names easier to remember, while computers use IP addresses to communicate.

DNS helps find the IP address associated with a domain name.

Think of DNS as the phonebook of the internet.

2. Why Do We Need DNS?

Imagine if we had to remember the IP address of every website we visited.

For example:

  • Google: An IP address
  • YouTube: An IP address
  • Amazon: An IP address
  • Netflix: An IP address

It would be difficult to remember all these numbers.

Instead, we use simple domain names such as:

  • google.com
  • youtube.com
  • amazon.com
  • netflix.com

When we enter a domain name in the browser, DNS helps our computer find the corresponding IP address.

That's why DNS is an important part of internet communication.

3. How Does DNS Actually Work?

Now let's understand the interesting part.

Suppose you open your browser and enter:

www.example.com

How does your computer find the server hosting this website?

DNS resolution involves several components working together.

Before looking at the complete process, let's understand the four important components.

A. DNS Resolver

A DNS Resolver is the component that handles DNS queries on behalf of your computer.

Think of it as an assistant who searches for the IP address of a website for you.

Your DNS resolver might be provided by:

  • Your Internet Service Provider (ISP)
  • Google Public DNS (8.8.8.8)
  • Cloudflare DNS (1.1.1.1)

When you request a website, your computer sends a DNS query to the resolver.

If the resolver already has the answer in its cache, it can return it immediately.

Otherwise, it starts looking for the answer.

B. Root Nameserver

The Root Nameserver is the starting point of the DNS hierarchy.

There are 13 logical root server identities, operated by multiple organisations across many physical locations.

The Root Nameserver doesn't normally provide the actual IP address of the website.

Instead, it directs the resolver to the appropriate Top-Level Domain (TLD) nameserver.

For example, if you are looking for www.example.com, the Root Nameserver tells the resolver where to find information about .com domains.

C. TLD Nameserver

TLD stands for Top-Level Domain.

It is the last part of a domain name.

Examples:

Domain TLD
google.com .com
amazon.in .in
wikipedia.org .org
example.net .net

The TLD Nameserver helps the resolver find the authoritative nameserver responsible for a particular domain.

For example, when the resolver asks the .com TLD Nameserver about example.com, it provides the nameserver information for that domain.

D. Authoritative Nameserver

This is where the actual DNS records for a domain are maintained.

The Authoritative Nameserver knows the DNS information configured for a particular domain.

For example, it might contain a DNS record like this:

Field Value
Domain www.example.com
Record Type A
IP Address 93.184.216.34

When the resolver asks for the IP address of www.example.com, the Authoritative Nameserver returns the corresponding DNS record.

Now the resolver has the answer!

4. DNS Query Process: Step by Step

Let's connect all these components.

Suppose you type:

www.example.com

into your browser.

Here is what happens behind the scenes.

Step 1: Your computer sends a DNS query

Your computer first checks available DNS caches.

If it doesn't already have a valid answer, it sends a DNS query to a DNS Resolver.

Step 2: Resolver contacts the Root Nameserver

If the resolver doesn't know the answer, it contacts a Root Nameserver.

The Root Nameserver responds:

"I don't have the IP address, but you can find information about .com domains through the .com TLD Nameserver."

Step 3: Resolver contacts the TLD Nameserver

The resolver contacts the .com TLD Nameserver.

The TLD Nameserver responds:

"I don't have the website's IP address, but here are the authoritative nameservers responsible for example.com."

Step 4: Resolver contacts the Authoritative Nameserver

The resolver now contacts the authoritative nameserver for example.com.

It asks:

"What is the IP address of www.example.com?"

The authoritative nameserver checks its DNS records and returns the requested information.

For example:

www.example.com → 93.184.216.34

Step 5: Resolver returns the IP address

The DNS resolver sends the IP address back to your computer.

Your browser can now connect to the web server using that IP address.

Step 6: Website loads

Your browser establishes a connection to the server and requests the website.

Finally, the website appears on your screen!

That's how DNS resolution works.

5. What Are DNS Records?

DNS records contain information about domain names.

Different DNS record types are used for different purposes.

Here are some important DNS records you should know.

Record Type Purpose Example
A Maps a domain to an IPv4 address example.com → 192.0.2.1
AAAA Maps a domain to an IPv6 address example.com → IPv6 address
CNAME Points one domain name to another domain name www.example.com → example.com
MX Specifies mail servers for a domain Mail server information
NS Identifies authoritative nameservers Nameserver information
TXT Stores text information Domain verification

One important thing to remember:

An A record points to an IPv4 address, while a CNAME record points to another domain name.

These records are important when configuring domains and applications in AWS.

6. What Is DNS Caching and TTL?

Imagine you visit Google.

Your computer sends a DNS query, and the resolver finds Google's IP address.

Now, what happens if you visit Google again after a few seconds?

Does the resolver need to contact the Root, TLD, and Authoritative Nameservers again?

Usually, no!

The resolver can temporarily store the DNS response and reuse it for subsequent requests.

This is called DNS Caching.

TTL stands for Time To Live.

It determines how long a DNS record can be cached.

For example:

TTL = 3600 seconds

This means the DNS response can be cached for up to one hour.

Why is caching useful?

  • Reduces DNS lookup time.
  • Improves performance.
  • Reduces unnecessary DNS queries.
  • Helps reduce the load on DNS infrastructure.

7. What Is Amazon Route 53?

Now that we understand DNS, let's connect it to AWS.

Amazon Route 53 is AWS's managed Domain Name System (DNS) service.

It helps you manage domain names and route incoming requests to your applications and other resources.

Imagine you have deployed a Python FastAPI application on AWS ECS.

Your application is accessible through an Application Load Balancer.

However, you don't want users to access your application using a long AWS-generated load balancer address.

Instead, you want users to access it through:

api.mycompany.com

This is where Amazon Route 53 becomes useful.

You can configure a DNS record in Route 53 to direct users to your Application Load Balancer.

The simplified flow looks like this:

  1. A user enters api.mycompany.com in the browser.
  2. The DNS resolver looks up the domain.
  3. Route 53, acting as the authoritative DNS service, provides the configured DNS response.
  4. The browser connects to the destination through the Application Load Balancer.
  5. The load balancer forwards the request to your application running on ECS.

Now users can access your application using a simple domain name!

Important Route 53 Concepts

While exploring Route 53, you will come across these terms.

Hosted Zone

A Hosted Zone is a container for DNS records belonging to a domain.

For example, if you own mycompany.com, you can create a Hosted Zone for it and configure records such as:

  • www.mycompany.com
  • api.mycompany.com
  • mail.mycompany.com

Record Sets

These are the DNS records you configure inside a Hosted Zone.

For example, you can create an A record, CNAME record, MX record, or other supported record types.

Routing Policies

Route 53 supports different routing policies to control how DNS queries are answered.

Some important routing policies include:

  • Simple Routing: Routes traffic to a single resource.
  • Weighted Routing: Distributes traffic across multiple resources based on assigned weights.
  • Latency-Based Routing: Routes users to resources based on network latency.
  • Failover Routing: Routes traffic to a healthy resource when the primary resource becomes unavailable.
  • Geolocation Routing: Routes users based on their geographic location.
  • Geoproximity Routing: Routes traffic based on the geographic location of users and resources, with optional bias.

These routing policies become especially useful when building highly available and globally distributed applications.

8. DNS vs Amazon Route 53

You might wonder whether DNS and Route 53 are the same thing.

They are not.

DNS is the overall system used to translate domain names into IP addresses.

Amazon Route 53 is an AWS service that provides managed DNS functionality and additional routing features.

Think of it this way:

  • DNS is the concept.
  • Route 53 is one service that helps implement and manage DNS.

There are other DNS providers as well, such as Cloudflare and Google Cloud DNS.

9. What I Learned

While learning AWS through Cloud Quest, DNS was one of the concepts I wanted to understand beyond just remembering definitions.

The most important thing I learned is that when we enter a website name in a browser, several components work together behind the scenes to find the correct server.

Here is a quick recap:

Component Responsibility
DNS Resolver Searches for the requested DNS information
Root Nameserver Directs the resolver to a TLD nameserver
TLD Nameserver Directs the resolver to an authoritative nameserver
Authoritative Nameserver Provides the actual DNS records
Amazon Route 53 AWS managed DNS service

Understanding these concepts makes it easier to work with AWS services such as Route 53, EC2, ECS, and Elastic Load Balancing.

Conclusion

DNS is one of the fundamental building blocks of the internet.

Every time we access a website using a domain name, DNS helps our computer find the correct destination.

If you are starting your AWS journey, I recommend understanding DNS resolution before moving on to Amazon Route 53 and its advanced routing features.

I hope this explanation helps someone who is learning DNS for the first time.

Happy Learning!

If you found this article useful, feel free to share your thoughts or ask questions in the comments.

References

Top comments (0)