Every time you open a website such as example.com, your browser eventually needs to communicate with a server identified by an IP address.
But humans generally prefer remembering names rather than numerical addresses.
This is where DNS comes in.
DNS is one of the fundamental systems behind the internet. Without it, users would have to remember IP addresses for many websites and online services.
What Does DNS Do?
At its simplest, DNS helps map a domain name to information needed to reach a service.
For example:
www.example.com
|
| DNS lookup
v
203.0.113.25
The browser can then use the resulting address to establish network communication with the destination.
DNS can also provide other records, such as information about mail servers, aliases, and domain verification.
Why Do We Need DNS?
Computers communicate using network addresses, while websites are easier for humans to remember using domain names.
Imagine having to remember an IP address for every website you use:
Website A → 203.0.113.25 Website B → 198.51.100.42 Website C → 192.0.2.10
Remembering names is much easier:
example.com blog.example.com api.example.com
DNS provides the translation and service-discovery layer between human-friendly names and network infrastructure.
DNS in One Simple Diagram
User enters:
https://www.example.com
|
v
Browser
|
v
DNS Resolver
|
v
DNS Infrastructure
|
v
IP Address
|
v
Web Server
|
v
Website
What Is a Domain Name?
A domain name is a human-readable name used to identify a domain in the DNS namespace.
Examples include:
- example.com
- google.com
- github.com
- codewithav.blogspot.com
A domain name can contain multiple labels separated by dots.
Understanding a Domain Name
Consider:
www.example.com
It can be viewed as:
www . example . com | | | | | +-- Top-Level Domain | +---------- Domain label +----------------------- Subdomain
Subdomain
www can be a subdomain label.
Other examples include:
blog.example.com api.example.com mail.example.com
Domain
example is the domain label in this simplified breakdown.
Top-Level Domain
.com is the top-level domain, commonly called a TLD.
What Is a TLD?
TLD stands for Top-Level Domain.
Common examples include:
- .com
- .org
- .net
- .edu
- .gov
- .in
There are many other generic and country-code top-level domains.
What Is DNS Resolution?
DNS resolution is the process of finding DNS information associated with a domain name.
When your browser needs to connect to a hostname, the system may perform a DNS lookup to find the relevant address.
A simplified flow is:
Domain Name
↓
Local Cache
↓
DNS Resolver
↓
Root DNS
↓
TLD DNS
↓
Authoritative DNS
↓
DNS Answer
↓
Client
In real systems, caching can cause some of these steps to be skipped because the resolver may already know the answer.
What Happens During a DNS Lookup?
Let's imagine that you enter:
https://www.example.com
Your system needs to determine the network address for www.example.com.
Step 1: Browser Cache
The browser may have recently resolved the hostname and may have cached the result.
Step 2: Operating System Cache
The operating system may also have cached DNS information.
Step 3: DNS Resolver
If no usable cached answer is available locally, the query can be sent to a recursive DNS resolver.
Step 4: Resolver Finds the Answer
The resolver can query the DNS hierarchy when it needs to obtain the answer.
Step 5: Result Is Returned
The resolver returns the DNS response to the client and may cache it according to applicable caching rules.
What Is a DNS Resolver?
A DNS resolver, often called a recursive resolver, receives DNS queries from clients and works to find the requested DNS information.
It can communicate with other DNS servers on behalf of the client.
Your Computer
|
v
Recursive DNS Resolver
|
+---- Root
|
+---- TLD
|
+---- Authoritative DNS
|
v
Answer
Resolvers also commonly maintain caches to reduce repeated DNS lookups.
What Is an Authoritative DNS Server?
An authoritative DNS server is a DNS server that provides the authoritative information for a particular DNS zone.
For example, an authoritative server for a domain can hold records such as:
- A
- AAAA
- CNAME
- MX
- TXT
- NS
When a recursive resolver reaches the authoritative source for a domain, it can obtain the relevant DNS record.
Recursive Resolver vs Authoritative DNS Server
| Recursive Resolver | Authoritative Server |
|---|---|
| Finds DNS answers for clients | Provides authoritative DNS data |
| Uses caching | Hosts zone data |
| May contact multiple DNS servers | Answers for zones it serves |
What Is the DNS Root?
At the top of the DNS hierarchy is the root.
The root DNS system helps direct queries toward the appropriate top-level domain infrastructure.
Root
|
+-----------+-----------+
| | |
.com .org .in
| | |
v v v
Domains Domains Domains
The root system does not normally contain the final IP address for every website. Instead, it helps resolvers discover where information for the relevant TLD can be found.
What Is a TLD DNS Server?
A TLD DNS server handles DNS information for domains under a particular top-level domain.
For example, .com DNS infrastructure helps resolvers locate authoritative nameservers for domains ending in .com.
What Is a DNS Zone?
A DNS zone is an administrative portion of the DNS namespace for which a set of authoritative records is maintained.
A zone can contain records describing how domain names should be resolved.
What Are DNS Records?
DNS records are pieces of information stored in DNS zones.
Different record types serve different purposes.
Important DNS Record Types
A Record
An A record maps a hostname to an IPv4 address.
example.com → 203.0.113.25
AAAA Record
An AAAA record maps a hostname to an IPv6 address.
example.com → 2001:db8::25
CNAME Record
A CNAME record creates an alias from one hostname to another hostname.
www.example.com
↓
example.com
CNAME records point to another domain name rather than directly to an IP address.
MX Record
MX records specify mail servers responsible for receiving email for a domain.
example.com
|
v
MX
|
v
mail.example.com
TXT Record
TXT records contain text data associated with a domain.
They are commonly used for purposes such as domain verification and email-related policies.
NS Record
NS records identify authoritative nameservers for a DNS zone.
PTR Record
PTR records are used for reverse DNS, mapping an IP address to a hostname.
DNS Record Comparison
| Record | Purpose |
|---|---|
| A | Hostname → IPv4 address |
| AAAA | Hostname → IPv6 address |
| CNAME | Hostname alias → another hostname |
| MX | Mail server information |
| TXT | Text-based domain information |
| NS | Authoritative nameservers |
| PTR | Reverse DNS mapping |
What Is a Nameserver?
A nameserver is a DNS server that answers DNS queries for a domain or zone.
When you register a domain, the domain's delegation includes nameserver information indicating which authoritative DNS servers are responsible for the domain.
A domain might use nameservers such as:
ns1.example-dns.com ns2.example-dns.com
DNS Delegation
DNS delegation is the process through which responsibility for a portion of the DNS namespace is delegated to authoritative nameservers.
For example:
Root ↓ .com ↓ example.com ↓ Authoritative Nameservers
This hierarchical structure allows DNS information to be distributed rather than stored in one enormous database.
What Is DNS Caching?
DNS caching means temporarily storing DNS responses so they can be reused for future requests.
Caching can occur at multiple levels, including:
- Browser
- Operating system
- Local network
- Recursive resolver
Caching reduces repeated queries and can improve response time.
What Is TTL in DNS?
TTL stands for Time to Live.
In DNS, TTL specifies how long a cached DNS record can generally be retained before it needs to be refreshed according to DNS caching behavior.
For example:
example.com A 203.0.113.25 TTL: 3600
A TTL of 3600 seconds represents one hour.
Why Does DNS Propagation Take Time?
When a DNS record changes, users may not immediately see the new result everywhere because different recursive resolvers can have cached versions of the previous record.
The time required for caches to refresh depends on factors such as the previous TTL and resolver behavior.
This is commonly described as DNS propagation, although DNS changes are essentially being observed as cached information expires and new information is obtained.
What Is Reverse DNS?
Normal DNS commonly maps a hostname to an IP address.
example.com
↓
203.0.113.25
Reverse DNS performs the opposite type of lookup:
203.0.113.25
↓
hostname.example.com
Reverse DNS commonly uses PTR records.
DNS and Email
DNS is not only used for websites.
Email systems rely heavily on DNS records.
MX records tell sending mail systems which servers are responsible for receiving mail for a domain.
TXT records can also be used for email-related authentication and policy mechanisms such as SPF, DKIM, and DMARC configurations.
DNS and Subdomains
A single domain can have multiple subdomains.
example.com ├── www.example.com ├── blog.example.com ├── api.example.com ├── mail.example.com └── shop.example.com
Each hostname can have its own DNS records and can point to different services.
DNS and Cloud Computing
DNS plays an important role in cloud environments.
Applications may use DNS for:
- Websites
- APIs
- Load balancers
- Microservices
- Cloud storage endpoints
- Email systems
- Service discovery
A production architecture might look like:
User | v DNS | v Load Balancer | +--------+--------+ | | | v v v App 1 App 2 App 3 | v Database
DNS and CDNs
DNS can also be part of how users are directed toward content delivery infrastructure.
Depending on the architecture, DNS can direct users to services that then route traffic through geographically distributed systems or edge infrastructure.
DNS and Cybersecurity
DNS is a major part of security monitoring because malicious infrastructure can use domains and DNS records to support phishing, malware distribution, command-and-control infrastructure, and other attacks.
Security teams may monitor:
- Suspicious domains
- Unexpected DNS changes
- Abnormal DNS query patterns
- Newly observed domains
- Large volumes of DNS requests
DNS filtering can also be used as one layer of defensive security.
What Is DNS Spoofing?
DNS spoofing refers broadly to attacks in which false DNS information is supplied to redirect users or systems.
Depending on the attack, a victim may be directed toward an attacker-controlled destination instead of the intended service.
DNS security therefore depends on proper resolver configuration, DNS infrastructure protection, and additional security mechanisms.
What Is DNS Cache Poisoning?
DNS cache poisoning is an attack in which incorrect DNS information is placed into a resolver's cache so that users can receive a fraudulent DNS answer.
Modern DNS infrastructure incorporates mechanisms intended to make such attacks more difficult, and DNSSEC can provide additional authenticity protections for DNS data.
What Is DNSSEC?
DNSSEC stands for Domain Name System Security Extensions.
DNSSEC adds cryptographic signatures to DNS data so resolvers that perform validation can verify that the DNS response originated from the expected DNS data chain and was not improperly modified.
DNSSEC helps address the authenticity and integrity of DNS data.
It does not encrypt ordinary DNS queries or provide general website encryption. HTTPS serves a different purpose.
DNS vs HTTPS
| DNS | HTTPS |
|---|---|
| Resolves domain information | Protects HTTP communication |
| Helps locate network services | Provides TLS encryption and authentication for web communication |
| Uses DNS protocols and records | Uses HTTP over TLS |
What Is DNS over HTTPS?
DNS over HTTPS (DoH) is a method of sending DNS queries through HTTPS.
This can protect the DNS query from being exposed as ordinary plaintext to network observers on the path between the client and the DoH server.
It is different from DNSSEC:
- DNSSEC focuses on authenticity and integrity of DNS data.
- DoH transports DNS queries and responses through HTTPS.
What Is DNS over TLS?
DNS over TLS (DoT) is another approach for protecting DNS traffic in transit by sending DNS through a TLS connection.
DoH and DoT solve related transport-privacy problems using different protocols and deployment models.
DNS Ports
Traditional DNS commonly uses UDP port 53.
DNS can also use TCP port 53, including for cases where TCP is required by the protocol or DNS data exchange.
Other DNS-related technologies use different ports. For example, DNS over TLS commonly uses TCP port 853.
How to Check DNS Records
You can inspect DNS information using command-line tools.
Windows nslookup
nslookup example.com
Linux dig
dig example.com
You can also query specific record types.
dig example.com A dig example.com AAAA dig example.com MX dig example.com TXT
Example DNS Lookup Using nslookup
A simplified command is:
nslookup example.com
The response can contain information such as the DNS server used and the returned address records.
The exact output depends on the operating system and DNS environment.
Common DNS Problems
1. NXDOMAIN
NXDOMAIN indicates that the queried domain name does not exist according to the responding DNS system.
2. SERVFAIL
SERVFAIL indicates that the DNS server could not successfully complete the query.
Potential causes can include DNSSEC validation issues, upstream failures, or authoritative configuration problems.
3. DNS Timeout
A DNS timeout can occur when the client or resolver does not receive an expected response within the relevant period.
4. Incorrect A or AAAA Record
If an A or AAAA record points to the wrong destination, visitors may be directed to the wrong server.
5. Incorrect Nameservers
If domain delegation points to the wrong nameservers, the intended DNS zone may not be used.
6. Stale Cached Information
Resolvers may temporarily return previously cached information until it expires according to TTL and caching behavior.
How to Troubleshoot DNS Problems
A practical troubleshooting sequence is:
- Check the domain name for spelling mistakes.
- Query the domain using nslookup or dig.
- Check the authoritative nameservers.
- Inspect A, AAAA, CNAME, MX, and TXT records as appropriate.
- Check the TTL and whether cached information may be involved.
- Test using a different recursive resolver.
- Check DNSSEC configuration when relevant.
- Verify that the destination server is actually reachable.
DNS and Website Hosting
When you connect a domain name to a website, DNS is usually part of the configuration.
A simplified setup might be:
Domain
example.com
|
v
DNS A Record
|
v
Web Server IP
|
v
Website
For some hosting platforms, other DNS configurations such as CNAME records or provider-specific records may be required.
DNS and Custom Domains
Suppose you want to connect a custom domain to a blog or web application.
The hosting platform may tell you to create one or more DNS records.
Depending on the platform, these could include:
- A records
- AAAA records
- CNAME records
- TXT verification records
The exact records should always come from the hosting provider's current documentation.
DNS and Subdomain Architecture
A single domain can provide separate services through subdomains.
example.com | +-- www.example.com → Website | +-- api.example.com → Backend API | +-- app.example.com → Web Application | +-- mail.example.com → Mail Service
This is common in modern application architectures.
DNS and Load Balancing
DNS can participate in traffic distribution, although the actual load-balancing behavior depends on the architecture and service involved.
A DNS name may resolve to infrastructure such as a load balancer rather than directly to an individual application server.
api.example.com
|
v
Load Balancer
/ | \
v v v
App1 App2 App3
Important DNS Concepts to Remember
| Concept | Simple Explanation |
|---|---|
| DNS | System for resolving domain names and related DNS information |
| Resolver | Finds DNS answers for clients |
| Authoritative Server | Provides authoritative records for a DNS zone |
| A Record | Hostname to IPv4 address |
| AAAA Record | Hostname to IPv6 address |
| CNAME | Alias from one hostname to another |
| MX | Mail server information |
| TXT | Text-based DNS information |
| TTL | Caching lifetime for DNS information |
Frequently Asked Questions
What is DNS in simple words?
DNS is the system that helps translate domain names into information such as IP addresses so computers can locate network services.
What does DNS stand for?
DNS stands for Domain Name System.
Why is DNS needed?
DNS lets people use memorable domain names instead of having to remember numerical network addresses for websites and other services.
What is DNS resolution?
DNS resolution is the process of finding the DNS information associated with a queried domain name.
What is a DNS resolver?
A DNS resolver receives queries from clients and works to find the appropriate DNS answer, often using cached information and other DNS servers.
What is an authoritative DNS server?
An authoritative DNS server provides the official DNS records for the zones it serves.
What is an A record?
An A record maps a hostname to an IPv4 address.
What is an AAAA record?
An AAAA record maps a hostname to an IPv6 address.
What is a CNAME record?
A CNAME record creates an alias from one hostname to another hostname.
What is an MX record?
An MX record identifies mail servers responsible for receiving email for a domain.
What is TTL in DNS?
TTL, or Time to Live, indicates how long DNS information can generally remain cached before it should be refreshed.
What is DNS propagation?
DNS propagation commonly refers to the time during which different DNS caches still contain previous information after a DNS change.
What is DNSSEC?
DNSSEC is a set of DNS extensions that uses cryptographic signatures to help validating resolvers verify the authenticity and integrity of DNS data.
What is the difference between DNS and HTTPS?
DNS helps resolve domain information, while HTTPS protects web communication using TLS.
What port does DNS use?
Traditional DNS commonly uses port 53 over UDP and can also use TCP. Other protected DNS methods use different transports and ports.
```Final Thoughts
DNS is one of the most important systems behind the internet.
It provides the naming and discovery mechanism that allows people to use names such as example.com while network infrastructure works with addresses and other machine-readable information.
For developers, network engineers, system administrators, cloud engineers, and cybersecurity learners, DNS fundamentals are essential.
Start by understanding domains, resolvers, authoritative servers, DNS hierarchy, A and AAAA records, CNAME, MX, TXT, nameservers, TTL, caching, and DNS troubleshooting.
Domain Names → DNS Resolution → Resolvers → Root → TLD → Authoritative DNS → A/AAAA → CNAME → MX/TXT → TTL & Caching → DNSSEC → DNS Troubleshooting.
Related Articles on CodeWithAV
What Is the Internet and How Does It Work?
What Happens When You Type a URL?
How a Website Works From Browser to Server
HTTP Status Codes Every Developer Should Know
Explore More Networking and Web Development Guides
CodeWithAV — Learn, Discover & Build.