DNS (Domain Name System) Tutorial 🌐📚

beginner
18 min

DNS (Domain Name System) Tutorial 🌐📚

Welcome to the DNS (Domain Name System) tutorial! In this lesson, we'll delve into the heart of the internet, exploring how DNS transforms human-friendly domain names into machine-readable IP addresses. Let's get started!

Understanding DNS 🎯

The Domain Name System (DNS) is the internet's telephone directory. It associates domain names like google.com with IP addresses like 172.217.10.74. This magical process makes navigating the web much easier for us humans!

How DNS Works 💡

  1. A user types a domain name in their web browser.
  2. The browser sends a request to a DNS resolver for the IP address associated with the domain name.
  3. The DNS resolver looks up the IP address in its cache, or queries other DNS servers, until it finds the correct IP address.
  4. Once the IP address is found, the browser establishes a connection with the server at that IP address and loads the website.

Key DNS Components 📝

Domain Names 🎯

A domain name is the unique address of a website on the internet. For example, example.com.

Top-Level Domains (TLDs) 🎯

TLDs are the last part of a domain name, such as .com, .org, and .net.

Subdomains 🎯

Subdomains are created by adding a label before the TLD, such as www.example.com.

IP Addresses 🎯

An IP address is a numerical label assigned to each device connected to a computer network that uses the internet.

DNS Records 📝

DNS records are data stored in a DNS database that maps domain names to IP addresses. Here are some common DNS record types:

A Record 📝

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

AAAA Record 📝

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

MX Record 📝

An MX record specifies the mail server responsible for handling email for a domain.

CNAME Record 📝

A CNAME record creates an alias for a domain name.

DNS Resolution Process 💡

When a user types a domain name into their browser, the DNS resolution process begins:

  1. The browser sends a request to a DNS resolver (usually the resolver provided by the user's internet service provider).
  2. The DNS resolver checks its cache for the IP address associated with the domain name.
  3. If the IP address is not in the cache, the resolver queries a root name server, which points it to the correct authoritative name server.
  4. The authoritative name server provides the correct IP address to the resolver, which caches the result for future use.
  5. The resolver returns the IP address to the browser, which establishes a connection with the server at that IP address and loads the website.

Practical Example 📝

Let's explore a practical example using the domain name example.com.

bash
# Query the IP address of example.com nslookup example.com # Output Server: 8.8.8.8 Address: 8.8.8.8 8.8.4.4 Non-authoritative answer: Name: example.com Address: 172.217.10.74

In this example, we're using Google's public DNS servers to query the IP address associated with example.com. The output shows that the IP address is 172.217.10.74.

Quiz 📝

Quick Quiz
Question 1 of 1

What is the purpose of DNS?

Quick Quiz
Question 1 of 1

What does an A record do?