DNS (Domain Name System) — Translating Domain Names into IP Addresses¶
DNS (Domain Name System) is the Internet's distributed naming system that translates human-readable domain names (such as
google.com) into IP addresses that computers use for communication. Without DNS, users would need to remember numerical IP addresses instead of simple domain names. Understanding DNS is essential for Linux administrators, DevOps engineers, Cloud Architects, Network Engineers, and Site Reliability Engineers (SREs).
Learning Path¶
Course Progress
What You'll Learn¶
After completing this lesson, you'll be able to:
- Understand DNS
- Learn how name resolution works
- Understand DNS records
- Configure DNS servers
- Troubleshoot DNS issues
- Use common DNS tools
- Apply DNS concepts in production
Prerequisites¶
Complete:
- Module 1 – Linux Fundamentals
- Module 2 – Linux Command Line Essentials
- Module 3 – Text Processing
- Module 4 – File Management
- Module 5 – Users and Groups
- Module 6 – Process Management
- Module 7 – Package Management
- Module 8 Lessons 1–2
Why Learn DNS?¶
Imagine you type:
Your browser does not know Google's IP address.
Instead,
it asks a DNS server:
"What is the IP address of
www.google.com?"
Only after receiving the IP address can your browser connect to the website.
What is DNS?¶
DNS stands for:
Its primary job is:
Example:
This process is called name resolution.
Why DNS is Needed¶
Without DNS,
users would have to remember addresses like:
Instead of:
DNS makes networking user-friendly.
DNS Resolution Process¶
User
│
▼
Browser
│
▼
Local DNS Resolver
│
▼
Recursive DNS Server
│
▼
Authoritative DNS Server
│
▼
IP Address Returned
│
▼
Browser Connects
DNS Components¶
The DNS infrastructure includes:
- Client (Resolver)
- Recursive DNS Server
- Root DNS Server
- Top-Level Domain (TLD) Server
- Authoritative DNS Server
Each plays a role in locating the correct IP address.
Common DNS Record Types¶
| Record | Purpose |
|---|---|
| A | Maps a hostname to an IPv4 address |
| AAAA | Maps a hostname to an IPv6 address |
| CNAME | Creates an alias for another hostname |
| MX | Specifies mail servers |
| NS | Specifies authoritative name servers |
| TXT | Stores text information (SPF, DKIM, verification, etc.) |
| PTR | Reverse DNS (IP address to hostname) |
| SRV | Specifies the location of network services |
A Record¶
Maps a hostname to an IPv4 address.
Example:
AAAA Record¶
Maps a hostname to an IPv6 address.
Example:
CNAME Record¶
Creates an alias.
Example:
Useful when multiple hostnames should point to the same destination.
MX Record¶
Specifies mail servers.
Example:
Email systems use MX records to determine where to deliver messages.
NS Record¶
Identifies authoritative name servers.
Example:
PTR Record¶
Performs reverse DNS lookup.
Commonly used for:
- Mail servers
- Logging
- Security
DNS Port¶
DNS uses:
Protocols:
- UDP 53 (most queries)
- TCP 53 (zone transfers and larger responses)
Configure DNS Servers¶
View configured DNS servers.
Example:
On many modern Linux distributions,
/etc/resolv.confis automatically managed by services such as systemd-resolved or NetworkManager. Direct edits may not persist.
Test DNS Resolution¶
Using getent (works with the system's configured name service):
Example:
Using dig¶
Query DNS.
Query a specific record.
Query a specific DNS server.
Using nslookup¶
Basic lookup.
Lookup using a specific server.
Reverse DNS Lookup¶
Using dig.
Using nslookup.
Flush DNS Cache¶
If using systemd-resolved:
Verify cache statistics.
Common Commands¶
View DNS configuration.
Resolve hostname.
DNS query.
DNS lookup.
Reverse lookup.
Real Production Examples¶
Verify Kubernetes API DNS.
Check mail records.
Verify website.
Check reverse DNS.
Production Perspective¶
DNS is critical for:
- Web applications
- Cloud infrastructure
- Kubernetes clusters
- Load balancers
- Email delivery
- Databases
- API communication
- Service discovery
A DNS outage can make applications unreachable even when the servers themselves are running.
Hands-on Lab¶
Task 1¶
View DNS configuration.
Task 2¶
Resolve a hostname.
Task 3¶
Query DNS using dig.
Task 4¶
Check mail records.
Task 5¶
Perform a reverse lookup.
Task 6¶
Use nslookup.
Task 7¶
Query a specific DNS server.
Task 8¶
View DNS cache statistics (if using systemd-resolved).
Command Deep Dive¶
| Command | Purpose | Production Example |
|---|---|---|
cat /etc/resolv.conf | View DNS configuration | Verify DNS servers |
getent hosts | Resolve hostnames | Verify name resolution |
dig | Advanced DNS queries | Troubleshooting |
nslookup | Basic DNS queries | Verification |
dig -x | Reverse lookup | Email troubleshooting |
resolvectl | Manage DNS cache | Cache maintenance |
Production Troubleshooting Scenario¶
Scenario
Users report that a web application is unreachable.
Investigation:
Test network connectivity.
The ping succeeds.
Test DNS resolution.
No response is returned.
Check DNS configuration.
The configured DNS server is unreachable.
Update the DNS configuration using the system's network management tool, then verify:
The hostname now resolves successfully, and the application becomes accessible.
Best Practices¶
- Use reliable and redundant DNS servers.
- Prefer managing DNS through the operating system's network configuration tools rather than editing
/etc/resolv.confdirectly. - Verify both forward and reverse DNS when troubleshooting.
- Use
digfor detailed DNS analysis. - Monitor DNS latency and availability.
- Configure multiple DNS servers for redundancy.
Common Mistakes¶
❌ Assuming every connectivity issue is caused by DNS.
✅ Verify every connectivity issue is caused by DNS instead of assuming it.
❌ Editing /etc/resolv.conf directly on systems where it is automatically managed.
✅ Edit /etc/resolv.conf directly on systems where it is automatically managed only when appropriate and with a backup.
❌ Configuring only one DNS server.
✅ Avoid this mistake: configuring only one DNS server.
❌ Ignoring DNS caching during troubleshooting.
✅ Always review DNS caching during troubleshooting.
Interview Questions¶
Beginner¶
- What does DNS stand for?
- Why is DNS important?
- Which port does DNS use?
- What is an A record?
Intermediate¶
- What is the difference between an A record and a CNAME record?
- What is the purpose of an MX record?
- How do you perform a reverse DNS lookup?
- What is the difference between
digandnslookup?
Architect Level¶
- How would you design a highly available DNS architecture?
- How would you troubleshoot intermittent DNS failures in a Kubernetes cluster?
- Why is DNS a critical dependency for cloud-native applications?
Summary¶
In this lesson, you learned:
- DNS fundamentals
- Name resolution
- DNS records
- DNS configuration
- DNS troubleshooting
- Common DNS tools
- Production DNS best practices
DNS is one of the most important services in modern networking. It enables users and applications to communicate using human-readable names instead of IP addresses, making networks scalable and easier to manage.
Key Takeaways¶
- DNS translates domain names into IP addresses.
- DNS commonly uses UDP port 53 and TCP port 53.
- A records map hostnames to IPv4 addresses.
- AAAA records map hostnames to IPv6 addresses.
- Use
digandnslookupto troubleshoot DNS. - Reliable DNS is essential for production applications.
What's Next?¶
Routing — How Linux Sends Network Traffic
You'll explore:
- What routing is
- Routing tables
- Default gateways
- Static and dynamic routing
- The
ip routecommand - Route troubleshooting
- Production networking best practices
Understanding routing will help you determine how Linux systems decide where to send network traffic.