What does DNS do, what protocol/port does it use, and why is it described as "operating on Layer 7 but providing services for Layer 3"?
DNS translates domain names to IP addresses. It uses UDP port 53 for queries (TCP for large/zone transfers). It's an application-layer protocol, but its output (an IP) is what enables Layer 3 communication.

* How a domain name splits into the DNS hierarchy's labels., CC0, via Wikimedia Commons. *
The basics:
You: "What's the IP of www.google.com?"
DNS: "142.250.179.196"
Protocol details:
| Property | Value |
|---|---|
| Layer | 7 (Application) |
| Transport | UDP (default) |
| Port | 53 |
| Fallback | TCP 53 (for responses > 512 bytes, zone transfers, DNSSEC) |
Why "Layer 7 but for Layer 3":
DNS itself is just an app sending UDP queries. But its purpose is to enable other layers — without DNS resolution, you can't make any hostname-based connection at any layer.
You type "google.com" in browser
↓
1. DNS query (Layer 7 service) ← DNS happens here
↓
2. DNS returns 142.250.179.196
↓
3. TCP handshake to 142.250.179.196:443 (Layer 4)
↓
4. IP routing to that address (Layer 3)
↓
5. HTTPS request (Layer 7 again)
The DNS hierarchy:
. (root)
└── com. (TLD)
└── google.com. (authoritative)
└── www.google.com. (host)
Resolution walks this tree from right to left if not cached.
Common record types:
| Type | Purpose |
|---|---|
A |
IPv4 address |
AAAA |
IPv6 address |
MX |
Mail server |
CNAME |
Alias to another name |
TXT |
Arbitrary text (SPF, DKIM, verification) |
NS |
Authoritative name server |
PTR |
Reverse — IP → name |
Tip: DNS over HTTPS (DoH) and DNS over TLS (DoT) encrypt queries to prevent ISPs from logging or hijacking. Default in Firefox/Chrome with Cloudflare/Google DoH endpoints.
Go deeper:
Domain Name System (Wikipedia) — the resolution hierarchy, message format, record types, and the recursion vs iteration distinction.