DNS Resolution & Record Architecture
Before opening a TCP socket or upgrading to a WebSocket, the browser resolves the target hostname into an IPv4 or IPv6 address through the Domain Name System (DNS).
1. Step-by-Step Resolution Chain
- Browser & OS Cache: Checks local host caches first.
- Recursive Resolver: Queries root, TLD, and authoritative nameservers.
- Authoritative Answer: Returns the IP record and its Time-To-Live (TTL).
2. Core DNS Record Types
| Type | Target | Behavior |
|---|---|---|
A | IPv4 | Maps a hostname to a 32-bit IPv4 address. |
AAAA | IPv6 | Maps a hostname to a 128-bit IPv6 address. |
CNAME | Hostname | Aliases one hostname to another canonical domain. |
TXT | UTF-8 Text | Stores verification tokens and policy records. |
3. TTL & Negative Caching
Resolvers cache records for their TTL in seconds. Missing domains (NXDOMAIN) are cached using the zone's SOA minimum TTL.
4. DoH vs. DoT
- DNS over TLS (DoT): Sends DNS wire messages over TLS on TCP port
853. - DNS over HTTPS (DoH): Sends DNS messages inside HTTPS requests on port
443.