What happens when you hit a URL? (DNS, TCP, TLS)
MediumNetworkingDNSTLS
What happens, at the network level, when you run curl https://example.com? Walk through DNS, TCP and TLS.
TL;DR
- DNS: the client resolves
example.comto an IP: local cache, then a recursive resolver, which asks the root, the.comTLD and finally the domain's authoritative server. Answers are cached for their TTL. - TCP: a three-way handshake (
SYN,SYN-ACK,ACK) to port 443 opens a reliable connection. - TLS 1.3: a one-round-trip handshake agrees on keys, and the server proves its identity with a certificate that chains up to a trusted CA and matches the hostname.
- HTTP: the encrypted request goes out, possibly through a CDN, load balancer and reverse proxy, and the response comes back.
Key points
- Record types: A/AAAA (IPv4/IPv6), CNAME (alias), MX (mail), TXT (verification, SPF), NS (delegation).
- Lower the TTL before a migration so clients pick up the new IP quickly.
- TCP adds reliability (ordering, retransmits) and flow control; that costs one round trip. QUIC (HTTP/3) runs on UDP and merges the transport and TLS handshakes.
- TLS gives encryption, integrity and server authentication. mTLS also authenticates the client (common between services).
- Common failures map to steps: DNS (
NXDOMAIN, stale records), TCP (connection refused, timeouts from firewalls or security groups), TLS (expired certificate, hostname mismatch, missing intermediate certificate).
Example
bash
dig +short example.com # DNS
nc -vz example.com 443 # TCP reachability
openssl s_client -connect example.com:443 -servername example.com # TLS and cert chain
curl -v https://example.com # the whole thing, step by stepCommon follow-ups
- "Connection refused" vs "connection timed out"? Refused: the host answered, but nothing listens on that port. Timed out: packets are dropped, often by a firewall or security group.
- What is SNI? The hostname sent in the TLS handshake, so one IP can serve certificates for many domains.
What interviewers look for
Tip
Name the steps in order, and connect each step to the tool you'd debug it with and how it typically fails.
- Red flag: skipping DNS caching and TTLs, or saying TLS "just encrypts" without mentioning certificate validation.