Dns

18 min read3,574 words

DNS — Domain Name System

DNS (Domain Name System) is a distributed naming system that translates human-readable domain names into IP addresses and also provides other types of information about network services.

Exam definition

DNS is a distributed hierarchical naming system used to resolve domain names into IP addresses and to provide other DNS records such as mail servers, aliases, and service information.

For example:

google.com ↓ DNS ↓ 142.250.x.x

Instead of remembering an IP address, users can use:

https://google.com

1. Why Do We Need DNS?

Computers communicate using IP addresses.

For example:

142.250.195.14

Humans generally find names easier to remember:

google.com

DNS provides the mapping:

Domain Name ↓ DNS ↓ IP Address

So when you enter:

www.example.com

your device can find the IP address associated with that hostname.

2. Simple DNS Example

Suppose you type:

https://www.example.com

Your computer needs the server's IP.

It asks a DNS resolver:

Computer │ │ What is the IP of www.example.com? ↓ DNS Resolver │ │ Answer ↓ 93.184.216.34

Then the computer can connect to the destination IP.

3. DNS Is More Than "Domain → IP"

A common beginner definition is:

DNS converts domain names into IP addresses.

That's useful, but incomplete.

DNS can provide many types of information:

Domain │ ├── IPv4 address ├── IPv6 address ├── Mail server ├── Alias ├── Name servers ├── Text information └── Service information

This information is stored in DNS records.

4. DNS Operates at Which Layer?

DNS is normally considered an Application Layer protocol.

OSI Model ↓ Layer 7 — Application TCP/IP Model ↓ Application Layer

DNS commonly uses:

UDP 53

and can also use:

TCP 53

Modern encrypted DNS protocols may use other transports, such as HTTPS or TLS.

5. DNS Port

Traditional DNS uses:

UDP 53 TCP 53

UDP 53

Common for ordinary DNS queries because it has low overhead.

TCP 53

Used when TCP is required, including certain large-response or DNS operational scenarios.

A DNS server may therefore listen on both:

UDP 53 TCP 53

6. DNS Hierarchy

DNS is hierarchical.

Simplified:

. │ Root DNS Servers │ ┌───────────┼───────────┐ ↓ ↓ ↓ .com .org .np │ ↓ example │ ↓ www.example.com

The hierarchy starts at the:

Root

represented by:

.

7. Root

At the top of the DNS hierarchy is the root zone:

.

It doesn't normally contain the IP address of every website.

Instead, root DNS servers can direct resolvers toward the appropriate Top-Level Domain (TLD) servers.

Examples of TLDs:

.com .org .net .edu .gov .np .uk .in

8. TLD — Top-Level Domain

TLD is the part immediately below the root.

For:

www.example.com

the TLD is:

.com

For:

example.org

the TLD is:

.org

For:

example.com.np

the hierarchy includes:

.np

with com.np functioning as a domain level under the .np country-code hierarchy.

9. Authoritative DNS Server

An authoritative DNS server contains the authoritative DNS data for a DNS zone.

For example:

example.com ↓ Authoritative DNS Server ↓ A record ↓ 93.184.216.34

The authoritative server is the source of truth for records in that zone, subject to DNS delegation and zone configuration.

10. Recursive DNS Resolver

A recursive resolver performs DNS resolution on behalf of a client.

For example:

Your PC │ │ DNS query ↓ Recursive Resolver │ ├── Root ├── TLD └── Authoritative server │ ↓ Final answer

The resolver then returns the result to your computer.

11. Recursive vs Authoritative

This distinction is extremely important.

Recursive ResolverAuthoritative Server
Finds answers for clientsHolds authoritative DNS data
Queries other DNS serversAnswers for its zone
Caches responsesProvides zone records
Acts on behalf of clientActs as authority for a zone

Simplified:

Client ↓ Recursive Resolver ↓ Authoritative DNS

12. DNS Resolution Process

Suppose you request:

www.example.com

A simplified recursive resolution process is:

Client │ ↓ Recursive Resolver │ ↓ Root Server │ ↓ .com TLD Server │ ↓ example.com Authoritative Server │ ↓ IP address │ ↓ Recursive Resolver │ ↓ Client

13. Step-by-Step DNS Resolution

Step 1 — User enters domain

www.example.com

Step 2 — Browser/OS checks local information

The system may first check:

  • Browser DNS cache
  • Operating system DNS cache
  • Hosts file
  • Other local resolver mechanisms

If it already knows the answer, it may not need to perform a full external DNS lookup.

Step 3 — Query goes to recursive resolver

Computer │ │ DNS Query ↓ Recursive Resolver

The resolver may already have the answer in its cache.

Step 4 — Resolver checks root

If necessary:

Resolver ↓ Root

The root can direct it toward the .com TLD servers.

Step 5 — Resolver asks TLD server

Resolver ↓ .com TLD

The TLD server can provide a delegation to the authoritative name servers for example.com.

Step 6 — Resolver asks authoritative server

Resolver ↓ Authoritative Server

The authoritative server returns the requested record.

For example:

www.example.com A 93.184.216.34

Step 7 — Resolver caches the result

The recursive resolver can cache the answer according to its TTL.

Step 8 — Resolver responds to client

DNS Resolver ↓ 93.184.216.34 ↓ Your computer

Now the application can connect to that IP.

14. DNS Resolution Diagram

USER │ │ www.example.com ↓ ┌───────────┐ │ Client │ └─────┬─────┘ │ ↓ ┌──────────────────┐ │ Recursive Resolver│ └────────┬─────────┘ │ ↓ Root DNS Server │ ↓ .com TLD Server │ ↓ example.com Authoritative │ ↓ IP Address │ ↓ Recursive Resolver │ ↓ Client

15. DNS Records

DNS stores information in different record types.

The most important are:

A AAAA CNAME MX NS TXT SOA PTR SRV CAA

Let's understand them.

16. A Record

An A record maps a hostname to an IPv4 address.

Example:

example.com ↓ A ↓ 93.184.216.34

Format:

example.com → 93.184.216.34

Remember:

A = IPv4 address

17. AAAA Record

An AAAA record maps a hostname to an IPv6 address.

Example:

example.com ↓ AAAA ↓ 2001:db8::10

Remember:

A → IPv4 AAAA → IPv6

18. CNAME Record

CNAME = Canonical Name

It creates an alias from one hostname to another hostname.

Example:

www.example.com ↓ CNAME ↓ example.com

It says approximately:

www.example.com is an alias for example.com.

The resolver then resolves the target name.

19. MX Record

MX = Mail Exchange

It identifies mail servers responsible for receiving email for a domain.

Example:

example.com ↓ MX ↓ mail.example.com

Mail systems use MX records when determining where to deliver email.

MX records have priority values.

Example:

10 mail1.example.com 20 mail2.example.com

Lower preference value means higher priority.

20. NS Record

NS = Name Server

It identifies authoritative name servers for a zone.

Example:

example.com ↓ NS ↓ ns1.example-dns.com ns2.example-dns.com

These servers are responsible for authoritative DNS data for the zone.

21. TXT Record

TXT records contain text associated with a domain.

They are commonly used for:

  • Domain verification
  • SPF-related email policy
  • DKIM-related information
  • DMARC-related information
  • Other application-specific data

Example:

example.com ↓ TXT ↓ "verification=abc123"

22. PTR Record

PTR = Pointer

PTR records are commonly used for reverse DNS.

Normal DNS:

Domain → IP

Reverse DNS:

IP → Domain

Example:

93.184.216.34 ↓ PTR ↓ example.com

IPv4 reverse DNS commonly uses:

in-addr.arpa

IPv6 reverse DNS uses:

ip6.arpa

23. SOA Record

SOA = Start of Authority

It contains important information about a DNS zone.

It includes information such as:

  • Primary/authoritative server
  • Responsible party mailbox
  • Serial number
  • Refresh
  • Retry
  • Expire
  • Negative caching TTL

Example conceptually:

example.com ↓ SOA ↓ ns1.example.com

24. SRV Record

SRV = Service

It allows DNS to specify the location of services.

It can contain:

Service Protocol Priority Weight Port Target

For example, some applications can use SRV records to discover:

_service._tcp.example.com

and obtain the appropriate hostname and port.

25. CAA Record

CAA = Certification Authority Authorization

It allows a domain owner to specify which certificate authorities are authorized to issue certificates for the domain.

Conceptually:

example.com ↓ CAA ↓ Authorized CA

This is useful for certificate-management security.

26. DNS Record Summary

RecordPurpose
AHostname → IPv4
AAAAHostname → IPv6
CNAMEAlias → Canonical hostname
MXMail server
NSAuthoritative name server
TXTText/policy/verification information
PTRReverse DNS
SOAZone authority information
SRVService discovery
CAACertificate authority authorization

27. DNS Cache

DNS results are often cached.

Example:

First request: Client → Resolver → DNS hierarchy

Later:

Client → Resolver ↓ Cache hit ↓ Answer

This makes DNS much faster and reduces DNS traffic.

28. TTL

TTL = Time To Live

DNS records have a TTL that tells caching resolvers how long the record may generally be cached.

Example:

example.com A 93.184.216.34 TTL = 3600

Conceptually:

3600 seconds = 1 hour

After the cache lifetime expires, the resolver may need to obtain fresh information.

29. Why DNS Caching Is Important

Without caching:

Every request ↓ Root ↓ TLD ↓ Authoritative

That would create enormous DNS traffic.

With caching:

Request ↓ Cache ↓ Answer

This improves:

  • Speed
  • Efficiency
  • Scalability

30. DNS Query Types

A DNS query can request different types of information.

For example:

A AAAA MX NS TXT CNAME

Example:

"What is the A record for example.com?"

31. Recursive Query

In a recursive query, the client asks the resolver to obtain the final answer on its behalf.

Client │ │ "Find the IP for example.com." ↓ Resolver │ ├── Root ├── TLD └── Authoritative ↓ Answer │ ↓ Client

The client expects the resolver to return the answer or an error.

32. Iterative Query

In an iterative process, a DNS server can respond with the best information it currently has, such as a referral.

For example:

Resolver → Root ↓ "Ask .com" Resolver → .com ↓ "Ask example.com" Resolver → Authoritative ↓ Final answer

The resolver performs the next query itself.

33. Recursive vs Iterative

RecursiveIterative
Server is expected to obtain final answerServer gives best available answer/referral
Client asks resolver to resolveResolver asks DNS hierarchy iteratively
Common client → resolver relationshipCommon resolver → authoritative hierarchy process

34. DNS Query and Response

A simplified DNS exchange:

Client DNS Server UDP Source: 53000 UDP Destination: 53 │ │ Query: │ example.com A ├────────────────────> │ │ Response: │ example.com A │ 93.184.216.34 │ <────────────────────┤

35. DNS and UDP

Traditional DNS often uses UDP because:

  • Small overhead
  • Fast request/response
  • No connection establishment
DNS Query ↓ UDP ↓ IP

But DNS is not exclusively UDP.

DNS can use TCP when needed.

36. DNS and TCP

DNS can use TCP, including situations involving:

  • Large responses
  • Zone transfers
  • Truncation requiring retry
  • DNS operational requirements

For example:

DNS ↓ TCP 53

So don't write:

DNS always uses UDP.

Correct:

DNS commonly uses UDP 53, but TCP 53 is also used when required.

37. DNS Encryption

Traditional DNS queries are generally not encrypted at the DNS protocol level.

There are modern encrypted DNS technologies.

DNS over TLS — DoT

DNS ↓ TLS ↓ TCP ↓ Port 853

Common port:

TCP 853

38. DNS over HTTPS — DoH

DNS queries can also be carried through HTTPS.

DNS ↓ HTTPS ↓ TCP / HTTP transport

DoH commonly uses:

443

This makes DNS traffic look like other HTTPS traffic at the network level.

39. DNSSEC

DNSSEC = Domain Name System Security Extensions

DNSSEC helps provide data origin authentication and integrity protection for DNS data.

It helps protect against certain forms of DNS data manipulation.

Conceptually:

DNS ↓ DNSSEC signatures ↓ Resolver validates

Important:

DNSSEC does not encrypt ordinary DNS queries.

Its primary purpose is authentication/integrity of DNS data, not confidentiality.

40. DNS Spoofing

DNS spoofing involves providing false DNS information so a victim is directed to an unintended destination.

Normal:

bank.example ↓ Correct IP

Spoofed:

bank.example ↓ Attacker-controlled IP

Security technologies such as DNSSEC can help defend against some DNS data manipulation scenarios.

41. DNS Cache Poisoning

Suppose a resolver's cache is incorrectly populated:

bank.example ↓ Fake IP

Then clients using that resolver may receive the incorrect answer until the cache is corrected or expires.

This is called:

DNS cache poisoning

Modern DNS implementations use various protections, and DNSSEC can provide stronger validation when correctly deployed.

42. DNS Tunneling

DNS can carry arbitrary data inside DNS queries/responses.

For example:

Client │ │ DNS queries containing encoded data ↓ DNS Server

This can be abused for:

  • Command-and-control communication
  • Data exfiltration
  • Bypassing poorly configured network controls

From a defensive cybersecurity perspective, unusual DNS behavior can be monitored.

Potential indicators include:

  • Very long subdomains
  • High query volume
  • Random-looking labels
  • Unusual record types
  • High-entropy domain labels

43. DNS Reconnaissance

DNS is very important in authorized security assessment.

Useful information can include:

A AAAA MX NS TXT CNAME

For example, on a domain you own or are authorized to test:

dig example.com

A specific A record:

dig example.com A

MX records:

dig example.com MX

NS records:

dig example.com NS

TXT records:

dig example.com TXT

44. nslookup

Another common DNS tool:

nslookup example.com

Example:

Name: example.com Address: 93.184.216.34

You can also query a specific record type depending on the implementation/options.

45. host

Linux often provides:

host example.com

For example:

example.com has address 93.184.216.34

Specific records:

host -t MX example.com

46. /etc/resolv.conf

On many Linux systems, DNS resolver configuration can be viewed with:

cat /etc/resolv.conf

It may contain a resolver address such as:

nameserver 192.168.1.1

Modern Linux distributions may instead use a local resolver stub or a resolver service such as systemd-resolved, so /etc/resolv.conf may point to a local address rather than directly showing the upstream DNS provider.

47. DNS on Your Computer

A typical home network may look like:

Laptop │ │ DNS query ↓ Home Router / DNS Resolver │ ↓ ISP / Public Recursive Resolver │ ↓ DNS Hierarchy

The exact setup depends on your network configuration.

48. Public DNS Resolvers

Some organizations operate public recursive DNS services.

Examples include services operated by:

  • Google
  • Cloudflare
  • Quad9

The important concept is:

Your Device ↓ Recursive DNS Resolver ↓ DNS Infrastructure

You do not need to query the root servers directly from your laptop for normal DNS resolution.

49. DNS and Website Access

When you visit:

https://www.example.com

DNS is only one part of the process.

Simplified:

1. Enter domain ↓ 2. DNS resolution ↓ 3. Get IP address ↓ 4. Establish transport connection ↓ 5. TLS negotiation for HTTPS ↓ 6. HTTP request ↓ 7. Web server response

So:

DNS ≠ HTTP DNS ≠ HTTPS DNS helps find the destination.

50. DNS vs DHCP

These are often confused.

DHCP

Automatically provides network configuration such as:

IP address Subnet information Default gateway DNS server

DNS

Resolves names:

example.com ↓ IP address

Relationship:

DHCP ↓ Tells your computer which DNS resolver to use DNS ↓ Resolves domain names

51. DNS vs IP

DNS

Name ↓ Information

Example:

example.com ↓ 93.184.216.34

IP

Logical network address

Example:

93.184.216.34

DNS helps applications discover addresses and other service information.

52. DNS and MAC

DNS operates at the application layer.

MAC operates at the data-link layer.

Example:

DNS ↓ Find server IP ↓ IP ↓ Find next-hop/local destination ↓ MAC ↓ Ethernet/Wi-Fi transmission

These are different functions.

53. DNS Full Resolution Example

Let's put everything together.

You type:

www.example.com

Step 1

Your browser/OS checks local information.

Browser / OS cache

Step 2

If necessary, the query goes to:

Recursive Resolver

Step 3

Resolver may ask:

Root

Step 4

Root directs it toward:

.com TLD

Step 5

TLD directs it toward:

example.com authoritative servers

Step 6

Authoritative server returns:

www.example.com A 93.184.216.34

Step 7

Resolver caches the answer according to TTL.

Step 8

Your device receives the IP.

Step 9

Your browser connects to the server.

Browser ↓ 93.184.216.34

54. Complete DNS Architecture

ROOT │ ┌───────┴───────┐ │ │ .com .org │ ↓ TLD Name Servers │ ↓ ┌───────────────────┐ │ example.com │ │ Authoritative DNS │ └─────────┬─────────┘ │ ┌───────┼────────┐ ↓ ↓ ↓ A MX TXT │ │ │ ↓ ↓ ↓ IP Mail Verification

Client side:

Client ↓ Recursive Resolver ↓ DNS Hierarchy ↓ Authoritative Server ↓ Answer

55. DNS Important Terms

Domain Name

Human-readable name:

example.com

Hostname

A name identifying a host/service:

www.example.com

Resolver

Software/service that performs DNS resolution.

Recursive Resolver

Resolver that obtains answers on behalf of clients.

Authoritative Server

Server that provides authoritative DNS data for a zone.

Root Server

Provides referrals toward TLD servers.

TLD

Top-level domain:

.com .org .net .np

Zone

An administrative portion of the DNS namespace managed through DNS records and authoritative servers.

56. Domain Name Structure

Consider:

www.example.com.

The final dot represents the DNS root.

www → hostname/label example → domain label com → TLD . → root

Fully qualified:

www.example.com.

The final dot is normally hidden in everyday URLs and domain names.

57. Subdomains

A domain can have subdomains:

example.com │ ├── www.example.com ├── mail.example.com ├── api.example.com ├── blog.example.com └── shop.example.com

Each can point to different infrastructure.

For example:

www.example.com → Web server api.example.com → API server mail.example.com → Mail infrastructure

58. DNS Load Distribution

DNS can return multiple addresses.

Example:

example.com ↓ A ├── 192.0.2.10 ├── 192.0.2.11 └── 192.0.2.12

Applications/resolvers may use these addresses according to DNS behavior and client/server policies.

However, DNS itself is not a full replacement for dedicated load-balancing systems.

59. DNS Failover

DNS can also be part of availability architectures.

For example:

example.com │ ├── Server A │ └── Server B

If one service becomes unavailable, DNS-based systems can sometimes direct new clients toward another destination.

But DNS caching means changes are not always instantaneous.

60. Important DNS Security Concepts

Remember:

DNS Security │ ├── DNSSEC ├── DNS over TLS ├── DNS over HTTPS ├── Cache poisoning protection ├── DNS filtering ├── Monitoring └── DNS tunneling detection

Different technologies solve different problems.

DNSSEC → authenticity/integrity DoT/DoH → confidentiality of DNS transport

61. DNS Quick Revision

DNS │ ├── Full form: │ Domain Name System │ ├── Layer: │ Application Layer │ ├── Common ports: │ UDP 53 │ TCP 53 │ ├── Main purpose: │ Name resolution │ ├── A: │ IPv4 │ ├── AAAA: │ IPv6 │ ├── CNAME: │ Alias │ ├── MX: │ Mail server │ ├── NS: │ Name server │ ├── TXT: │ Text/policy/verification │ ├── PTR: │ Reverse DNS │ ├── SOA: │ Zone authority │ ├── SRV: │ Service discovery │ └── CAA: Certificate authority authorization

62. Most Important DNS Flow

Remember this:

User ↓ Domain Name ↓ Local Cache ↓ Recursive Resolver ↓ Root ↓ TLD ↓ Authoritative DNS ↓ IP Address ↓ Web/Application Server

For example:

www.example.com ↓ DNS ↓ 93.184.216.34 ↓ Server

63. DNS vs TCP vs UDP

These three work at different roles:

APPLICATION │ DNS │ ┌───────┴───────┐ ↓ ↓ TCP UDP │ │ └───────┬───────┘ ↓ IP

DNS is the application-layer protocol.

TCP/UDP are transport-layer protocols used to carry DNS traffic.

Final exam answer

DNS (Domain Name System) is a distributed hierarchical application-layer naming system that resolves domain names into IP addresses and provides other information through DNS records. Traditional DNS commonly uses UDP port 53 and can also use TCP port 53.

Keep learning. Keep building. Keep growing.

© 2026 Ugenz Academy