DEV Community

Cover image for DNS Explained: How Your Device Finds a Website on the Internet
Abdul Qayum Akindele
Abdul Qayum Akindele

Posted on

DNS Explained: How Your Device Finds a Website on the Internet

DNS Explained: How Your Device Finds a Website on the Internet

Have you ever wondered what happens behind the scenes when you type a website address like google.com into your browser?

You type a name.

A few seconds later, a website appears.

But computers don't naturally communicate using names like humans do. They communicate using IP addresses.

So how does your computer know that google.com should connect to a particular IP address?

This is where DNS comes in.

What Is DNS?

DNS stands for Domain Name System.

In simple terms, DNS translates domain names into IP addresses.

Think of it like the phonebook of the internet.

You probably don't remember someone's phone number just because you know their name. Instead, you save their name and your phone stores the number connected to it.

DNS works in a similar way.

For example:

Domain name: google.com
        ↓
DNS lookup
        ↓
IP address
Enter fullscreen mode Exit fullscreen mode

Instead of forcing humans to remember complicated IP addresses, DNS allows us to use names that are much easier to remember.


Why Do We Need DNS?

Imagine that every time you wanted to visit a website, you had to remember its IP address.

Instead of typing:

google.com
Enter fullscreen mode Exit fullscreen mode

you might have to enter something like:

142.250.xxx.xxx
Enter fullscreen mode Exit fullscreen mode

That would be difficult.

And websites can use multiple IP addresses, change infrastructure, or use different servers around the world.

DNS gives us a much easier system:

Humans use domain names.
Computers use IP addresses.

DNS acts as the system that connects the two.


What Happens When You Type a Website?

Let's say I type:

www.example.com
Enter fullscreen mode Exit fullscreen mode

into my browser.

What happens next?

It isn't simply:

Browser → Website

There is a process happening in the background.

A simplified version looks like this:

You
 ↓
Browser
 ↓
Your device checks its DNS cache
 ↓
DNS Resolver
 ↓
Root DNS Server
 ↓
TLD DNS Server
 ↓
Authoritative DNS Server
 ↓
IP Address
 ↓
Website
Enter fullscreen mode Exit fullscreen mode

Let's break it down.

1. Your Device Checks Its Cache

Before asking another DNS server, your device may already have the answer stored.

This is called DNS caching.

If your computer recently looked up a domain, it may remember the IP address for a certain period of time.

That means it doesn't always need to perform the entire DNS lookup again.

This makes the process faster.


2. Your Request Goes to a DNS Resolver

If the answer isn't available in your device's cache, the request can go to a recursive DNS resolver.

A DNS resolver is responsible for finding the IP address on your behalf.

Your internet provider may provide a DNS resolver automatically, but you can also use public DNS services such as:

  • 8.8.8.8 — Google Public DNS
  • 1.1.1.1 — Cloudflare DNS

The resolver then searches for the correct answer.


3. The Root DNS Server

If the resolver doesn't already know the answer, it can ask the root DNS system.

The root doesn't normally give the final IP address of the website.

Instead, it helps direct the resolver toward the correct Top-Level Domain (TLD) servers.

For example, if the domain is:

example.com
Enter fullscreen mode Exit fullscreen mode

the .com part is the TLD.

The root system can point the resolver toward the servers responsible for .com.


4. The TLD DNS Server

The TLD server is responsible for a particular top-level domain.

Examples include:

.com
.org
.net
.ng
.edu
Enter fullscreen mode Exit fullscreen mode

For example.com, the resolver communicates with the .com TLD infrastructure.

The TLD server can then point the resolver toward the authoritative DNS server for example.com.


5. The Authoritative DNS Server

Now we get closer to the actual answer.

The authoritative DNS server contains the DNS records for the domain.

It can provide information such as the IP address associated with the domain.

For example:

example.com → IP address
Enter fullscreen mode Exit fullscreen mode

The resolver receives that information and sends the answer back to your device.


6. Your Browser Connects to the Website

Now your computer knows where to go.

The DNS process has provided the IP address.

Your browser can then establish a connection with the server hosting the website.

So the simplified journey becomes:

You type a domain
        ↓
DNS lookup
        ↓
IP address found
        ↓
Browser connects to server
        ↓
Website loads
Enter fullscreen mode Exit fullscreen mode

And all of this can happen extremely quickly.


DNS Records

DNS isn't only about finding an IP address.

DNS uses different types of records to store different kinds of information.

Here are some important ones.

A Record

An A record maps a domain name to an IPv4 address.

example.com → 192.0.2.1
Enter fullscreen mode Exit fullscreen mode

AAAA Record

An AAAA record maps a domain name to an IPv6 address.

example.com → IPv6 address
Enter fullscreen mode Exit fullscreen mode

CNAME Record

A CNAME can make one domain name point to another domain name.

For example:

www.example.com
        ↓
example.com
Enter fullscreen mode Exit fullscreen mode

MX Record

An MX record tells the internet which mail servers handle email for a domain.

TXT Record

A TXT record allows text information to be stored in DNS.

TXT records are also commonly used for domain verification and email-security mechanisms.


DNS and Cybersecurity

This is where DNS becomes especially interesting to me as someone learning cybersecurity.

DNS is a fundamental part of how we use the internet, but attackers can also abuse it.

For example, DNS can be involved in:

  • Phishing attacks
  • DNS spoofing
  • DNS hijacking
  • Malicious domain infrastructure
  • Command-and-control communication
  • DNS tunneling

This means DNS isn't just something we need to understand for networking.

It can also be useful when investigating suspicious activity.

For example, during security analysis, a cybersecurity professional might investigate which domains a device is communicating with.

DNS information can sometimes provide important clues.


Is DNS the Same as HTTPS?

No.

This is something I think beginners should understand.

DNS helps your device find where a domain is located.

HTTPS helps protect the communication between your browser and the website.

They perform different jobs.

A simplified example:

DNS
"Where is this website?"

HTTPS
"How can I communicate with this website securely?"
Enter fullscreen mode Exit fullscreen mode

Both are important, but they solve different problems.


What About 8.8.8.8 and 1.1.1.1?

You may have seen these addresses before.

8.8.8.8
1.1.1.1
Enter fullscreen mode Exit fullscreen mode

These are examples of public DNS resolver addresses.

They aren't different levels of DNS like the root, TLD, and authoritative servers.

Instead, they are services that can perform DNS resolution for users.

For example, you can configure a device or network to use a public resolver instead of the DNS resolver provided automatically by your internet service provider.


Why DNS Matters

Before learning about DNS, I thought of it mainly as something that helps connect a website name to an IP address.

And that's true—but there's more to it.

DNS is one of the systems quietly working in the background every time we use the internet.

When you open a website, send an email, or use an online service, DNS may be involved in helping your device locate the right destination.

Understanding DNS therefore gives you a better understanding of how the internet itself works.

And for someone learning cybersecurity, understanding how the underlying systems work is important.

You can't properly secure something you don't understand.


Final Thoughts

DNS may look complicated at first because there are different servers, records, resolvers, caches, and protocols involved.

But the basic idea is actually simple:

DNS helps translate human-friendly domain names into information computers can use to find services on the internet.

The next time you type a website into your browser and it loads almost instantly, remember that there is a whole system working behind the scenes.

You type a name.

DNS helps find the destination.

Then your browser connects to it.

That's the basic idea behind the Domain Name System.

And this is only the beginning.

I'm still learning cybersecurity, and DNS is one of those topics that reminds me that the internet is much deeper than what we see on the screen.

Keep learning. Keep questioning. Keep exploring.

OFF_LIMIT TECH

Have you ever wondered what happens behind the scenes when you type a website address like google.com into your browser?

You type a name.

A few seconds later, a website appears.

But computers don't naturally communicate using names like humans do. They communicate using IP addresses.

So how does your computer know that google.com should connect to a particular IP address?

This is where DNS comes in.

What Is DNS?

DNS stands for Domain Name System.

In simple terms, DNS translates domain names into IP addresses.

Think of it like the phonebook of the internet.

You probably don't remember someone's phone number just because you know their name. Instead, you save their name and your phone stores the number connected to it.

DNS works in a similar way.

For example:

Domain name: google.com
        ↓
DNS lookup
        ↓
IP address
Enter fullscreen mode Exit fullscreen mode

Instead of forcing humans to remember complicated IP addresses, DNS allows us to use names that are much easier to remember.


Why Do We Need DNS?

Imagine that every time you wanted to visit a website, you had to remember its IP address.

Instead of typing:

google.com
Enter fullscreen mode Exit fullscreen mode

you might have to enter something like:

142.250.xxx.xxx
Enter fullscreen mode Exit fullscreen mode

That would be difficult.

And websites can use multiple IP addresses, change infrastructure, or use different servers around the world.

DNS gives us a much easier system:

Humans use domain names.
Computers use IP addresses.

DNS acts as the system that connects the two.


What Happens When You Type a Website?

Let's say I type:

www.example.com
Enter fullscreen mode Exit fullscreen mode

into my browser.

What happens next?

It isn't simply:

Browser → Website

There is a process happening in the background.

A simplified version looks like this:

You
 ↓
Browser
 ↓
Your device checks its DNS cache
 ↓
DNS Resolver
 ↓
Root DNS Server
 ↓
TLD DNS Server
 ↓
Authoritative DNS Server
 ↓
IP Address
 ↓
Website
Enter fullscreen mode Exit fullscreen mode

Let's break it down.

1. Your Device Checks Its Cache

Before asking another DNS server, your device may already have the answer stored.

This is called DNS caching.

If your computer recently looked up a domain, it may remember the IP address for a certain period of time.

That means it doesn't always need to perform the entire DNS lookup again.

This makes the process faster.


2. Your Request Goes to a DNS Resolver

If the answer isn't available in your device's cache, the request can go to a recursive DNS resolver.

A DNS resolver is responsible for finding the IP address on your behalf.

Your internet provider may provide a DNS resolver automatically, but you can also use public DNS services such as:

  • 8.8.8.8 — Google Public DNS
  • 1.1.1.1 — Cloudflare DNS

The resolver then searches for the correct answer.


3. The Root DNS Server

If the resolver doesn't already know the answer, it can ask the root DNS system.

The root doesn't normally give the final IP address of the website.

Instead, it helps direct the resolver toward the correct Top-Level Domain (TLD) servers.

For example, if the domain is:

example.com
Enter fullscreen mode Exit fullscreen mode

the .com part is the TLD.

The root system can point the resolver toward the servers responsible for .com.


4. The TLD DNS Server

The TLD server is responsible for a particular top-level domain.

Examples include:

.com
.org
.net
.ng
.edu
Enter fullscreen mode Exit fullscreen mode

For example.com, the resolver communicates with the .com TLD infrastructure.

The TLD server can then point the resolver toward the authoritative DNS server for example.com.


5. The Authoritative DNS Server

Now we get closer to the actual answer.

The authoritative DNS server contains the DNS records for the domain.

It can provide information such as the IP address associated with the domain.

For example:

example.com → IP address
Enter fullscreen mode Exit fullscreen mode

The resolver receives that information and sends the answer back to your device.


6. Your Browser Connects to the Website

Now your computer knows where to go.

The DNS process has provided the IP address.

Your browser can then establish a connection with the server hosting the website.

So the simplified journey becomes:

You type a domain
        ↓
DNS lookup
        ↓
IP address found
        ↓
Browser connects to server
        ↓
Website loads
Enter fullscreen mode Exit fullscreen mode

And all of this can happen extremely quickly.


DNS Records

DNS isn't only about finding an IP address.

DNS uses different types of records to store different kinds of information.

Here are some important ones.

A Record

An A record maps a domain name to an IPv4 address.

example.com → 192.0.2.1
Enter fullscreen mode Exit fullscreen mode

AAAA Record

An AAAA record maps a domain name to an IPv6 address.

example.com → IPv6 address
Enter fullscreen mode Exit fullscreen mode

CNAME Record

A CNAME can make one domain name point to another domain name.

For example:

www.example.com
        ↓
example.com
Enter fullscreen mode Exit fullscreen mode

MX Record

An MX record tells the internet which mail servers handle email for a domain.

TXT Record

A TXT record allows text information to be stored in DNS.

TXT records are also commonly used for domain verification and email-security mechanisms.


DNS and Cybersecurity

This is where DNS becomes especially interesting to me as someone learning cybersecurity.

DNS is a fundamental part of how we use the internet, but attackers can also abuse it.

For example, DNS can be involved in:

  • Phishing attacks
  • DNS spoofing
  • DNS hijacking
  • Malicious domain infrastructure
  • Command-and-control communication
  • DNS tunneling

This means DNS isn't just something we need to understand for networking.

It can also be useful when investigating suspicious activity.

For example, during security analysis, a cybersecurity professional might investigate which domains a device is communicating with.

DNS information can sometimes provide important clues.


Is DNS the Same as HTTPS?

No.

This is something I think beginners should understand.

DNS helps your device find where a domain is located.

HTTPS helps protect the communication between your browser and the website.

They perform different jobs.

A simplified example:

DNS
"Where is this website?"

HTTPS
"How can I communicate with this website securely?"
Enter fullscreen mode Exit fullscreen mode

Both are important, but they solve different problems.


What About 8.8.8.8 and 1.1.1.1?

You may have seen these addresses before.

8.8.8.8
1.1.1.1
Enter fullscreen mode Exit fullscreen mode

These are examples of public DNS resolver addresses.

They aren't different levels of DNS like the root, TLD, and authoritative servers.

Instead, they are services that can perform DNS resolution for users.

For example, you can configure a device or network to use a public resolver instead of the DNS resolver provided automatically by your internet service provider.


Why DNS Matters

Before learning about DNS, I thought of it mainly as something that helps connect a website name to an IP address.

And that's true—but there's more to it.

DNS is one of the systems quietly working in the background every time we use the internet.

When you open a website, send an email, or use an online service, DNS may be involved in helping your device locate the right destination.

Understanding DNS therefore gives you a better understanding of how the internet itself works.

And for someone learning cybersecurity, understanding how the underlying systems work is important.

You can't properly secure something you don't understand.


Final Thoughts

DNS may look complicated at first because there are different servers, records, resolvers, caches, and protocols involved.

But the basic idea is actually simple:

DNS helps translate human-friendly domain names into information computers can use to find services on the internet.

The next time you type a website into your browser and it loads almost instantly, remember that there is a whole system working behind the scenes.

You type a name.

DNS helps find the destination.

Then your browser connects to it.

That's the basic idea behind the Domain Name System.

And this is only the beginning.

I'm still learning cybersecurity, and DNS is one of those topics that reminds me that the internet is much deeper than what we see on the screen.

Keep learning. Keep questioning. Keep exploring.

OFF_LIMIT TECH

Top comments (0)