E · 01 Computer Networks & Security

What Happens When You Type a URL?

What Happens When You Type a URL?

You type a URL and press Enter. 200 ms later, a page appears. Here's every step in between: DNS, TCP, TLS, HTTP, routing, CDNs, and rendering, plus where attackers can strike along the way.

Chapters

Transcript

You type example.com and press Enter. About 200 milliseconds later, a page appears. In that blink, your request was wrapped in layers, passed through a dozen strangers' machines, agreed on a secret key, and came back with your page. It's also one of the most common interview questions in software. Most people answer: DNS, then HTTP.

That's two stops on a journey with about eight. This series walks that journey, one stop per episode. Today, we'll fly over all of it, so you have the map.

This is Just Known. From unknown, to known. Here's the map. Actually, two maps. The first is the road: your laptop, your Wi-Fi router, your internet provider, routers across the internet, and finally a data center.

Every message in this story travels that road. The second is the conversation: find the address with DNS, open a connection with TCP, lock it with TLS, then ask for the page with HTTP. Let's take the fast tour. Stop one happens before anything touches the network. The browser reads what you typed.

Is it a search, or an address? It's an address, so the browser splits it up. You didn't type a scheme, so a modern browser assumes HTTPS. The host is example.com. The port defaults to 443.

And the path is just a slash: the home page. Then it checks for shortcuts. Is there a fresh copy in the cache? Is there already an open connection it can reuse? Every shortcut that hits skips part of the journey.

That's why a second visit is faster. Let's assume nothing is cached. Fresh start. Stop two: DNS. The internet doesn't route by names.

It routes by numbers. So the browser needs the IP address behind example.com. It checks its own cache, then the operating system's. If neither knows, the question goes to a recursive resolver, usually run by your internet provider, or a public one, like 1.1.1.1. If the resolver hasn't seen this name recently, it goes hunting.

It asks a root server, which says: I don't know example.com, but here's who runs .com. It asks the .com servers, which say: here's the name server for example.com. And that server, the authoritative one, gives the real answer: an IP address. On the way back, each cache stores the answer, with an expiry time called a TTL. So the next lookup is almost instant.

Hold on to that word, cache. It shows up at almost every stop. We'll dig into how resolution really works, and how attackers poison it, in episode 5. But that DNS question is itself a message. How does it leave your laptop?

Through layers. The question is the application data. Your operating system wraps it in a UDP header, which says which program should receive it: port 53. Then it adds an IP header, with the source and destination addresses. And finally, a Wi-Fi frame, addressed to your router.

Each device only reads the layer it needs. Your router ignores the DNS inside. It reads the outside and passes it on. That wrapping is called encapsulation, and the whole internet is built on it. Two quiet details are hiding here.

Your laptop got its IP address from the router through DHCP, and found the router's hardware address by asking everyone nearby, using ARP. And that IP address is private. On the way out, the router swaps it for your public address and remembers the swap, so replies find their way back. That's NAT. We'll unpack layers in episode 2, your local network in episode 3, and addresses and NAT in episode 4.

Now the packet is on the road: from your router to your provider, and from there, across the internet. No single machine knows the full path. Each router looks at one thing, the destination address, checks its routing table, and hands the packet to a neighbor that's a little closer. Hop. Hop.

Hop. Ten, fifteen, twenty routers, across networks run by different companies. Those networks tell each other which addresses they can reach, using a protocol called BGP, the closest thing the internet has to a global map. It runs largely on trust: when a network announces routes it shouldn't, traffic for a major website, or even a whole country, can get pulled the wrong way. And that has happened, more than once.

Every packet also carries a counter called time to live. Each router knocks it down by one, and at zero, the packet is dropped, so nothing loops forever. A tool called traceroute uses that exact rule to reveal every hop on the path. We'll explore routing and BGP in episode 6. Back to the conversation.

DNS gave us an address. Now the browser needs a reliable connection to it, on port 443. That's TCP. The internet itself makes no promises. Packets get lost, duplicated, or arrive out of order.

TCP builds a reliable stream on top of that chaos, and it starts with a handshake. The client sends a SYN: here's my starting sequence number. The server answers with a SYN-ACK: got yours, here's mine. The client replies with an ACK: got yours too. Now both sides know the other can hear them, and they've agreed how to number every byte, so anything lost can be resent.

That's one full round trip before your page is even requested. Remember that cost; we'll add it all up soon. Why three messages, and not two? That's a classic interview question, and we'll answer it in episode 7. Right now, anyone on the road could read this connection: your Wi-Fi network, your provider, every router in between.

So before anything private is sent, the browser and server run a TLS handshake. The browser says hello: here are the encryption methods I support, here's the site I want, and here's my half of a key exchange. The server answers with its half, plus its certificate: a signed document that says, this key really belongs to example.com. The browser checks that certificate. Does the name match?

Is it still valid? Was it signed by an authority your device already trusts? If anything fails, you get that big red warning page. If it passes, both sides combine their halves into the same secret key, without that key ever crossing the wire. That's the Diffie-Hellman trick, one of computing's most elegant ideas.

From here on, everything is encrypted and protected from tampering. With TLS 1.3, all of that costs just one more round trip. We'll cover cryptography in episode 9, and TLS and certificates in episode 10. Now, finally, the actual question. Inside that encrypted connection, the browser sends an HTTP request: get me the page at slash, from example.com.

Along with it go headers: which browser you're using, what formats you accept, and any cookies this site gave you before. Those cookies are how a site remembers that you're logged in. That request rarely reaches a single lonely server. Often it lands first at a CDN edge, a server close to you, which may answer straight from its cache. In fact, your TLS connection usually ends right there, at the edge, not at the origin.

If the edge can't answer, the request moves on to a load balancer, which picks one of many identical servers. That server runs the application code, maybe asks a database, and builds a response. The response starts with a status: 200, OK. Then headers: this is HTML, and here's how long you may cache it. Then the body: the page itself.

And it all makes the trip back, through the same layers, possibly along a different path. HTTP gets its own deep dive in episode 11, and load balancers and CDNs in episode 14. The browser reads the HTML and builds a tree of the page. Along the way, it finds more things it needs: stylesheets, scripts, images. Each one is another request.

It can reuse the connection it already paid for, and with HTTP/2, many requests share that one connection at the same time. Then it works out where every box goes, paints the pixels, and there's your page. So where did the time go? Say the server is 50 milliseconds away, there and back. An uncached DNS lookup: maybe 20 to 100 milliseconds.

The TCP handshake: one round trip, 50. TLS: another 50. The request and the first byte of the response: 50 more, plus however long the server takes to think. That's at least three round trips before the first byte arrives. And notice: most of that time isn't moving data.

It's waiting for the other side to reply. That's why so much of web performance is about cutting round trips. Caching skips the DNS lookup, and sometimes the whole request. Reusing connections skips the handshakes. CDNs move the server closer, so every round trip is shorter.

And HTTP/3 runs on a newer protocol called QUIC, which merges the connection and encryption handshakes into one. Now look at that road again, the way an attacker would. On public Wi-Fi, someone can run a fake hotspot, or trick your laptop into sending them the traffic meant for the router. A forged DNS answer can send you to the wrong address. A hijacked route can pull traffic through the wrong network.

A flood of fake handshakes can knock a server offline. And at the far end, the app itself can be attacked: injection, cross-site scripting, stolen sessions. So how is anything safe? Mostly, TLS. Even if an attacker controls the road, they can't read your traffic, can't change it unnoticed, and can't fake the certificate.

But TLS doesn't hide everything. Unless you use encrypted DNS, your lookups can be seen. The IP address you connect to is always visible. And the site's name usually travels unencrypted, in the very first hello. Encrypted, yes.

Invisible, no. Every episode has a segment like this, because you can't defend a system you don't understand. You can watch this whole journey from your own terminal. Run curl, dash v, on any HTTPS site. Every line maps to a stop.

"Trying," and an IP address: DNS is done. "Connected": the TCP handshake finished. A block of TLS lines: the handshake and certificate check. Lines starting with a right arrow: your request. Left arrow: the response.

Want the timing? curl can print it: the name lookup, the connection, the TLS handshake, and the first byte. Try a site you've never visited, run it twice, and the lookup time usually drops. That's caching. The exact command is in the description.

Interview corner. What happens when you type a URL and press Enter? Pause here, and try answering in thirty seconds.

Here's a strong answer. The browser parses the URL and checks its caches. DNS resolves the name to an IP address. The browser opens a TCP connection to port 443, then runs a TLS handshake to verify the server and set up encryption. It sends an HTTP request, which is routed hop by hop to the server, often through a CDN or load balancer.

The server responds, and the browser renders the page, fetching extra resources over the same connection. Now the move that separates good from great: offer to go deeper. "I can walk through DNS resolution, or the TLS handshake, whichever is more useful." Interviewers aren't checking whether you memorized a list. They're finding where your understanding stops.

Let's recap. Loading a page is a conversation, DNS, TCP, TLS, and HTTP, carried over a road of routers. Every message is wrapped in layers, and each device reads only the layer it needs. And most of the cost is round trips, which is why caching, connection reuse, and CDNs matter so much. Next stop: those layers.

Why does every packet wear four envelopes, and what's written on each one? This is Just Known. From unknown, to known.

Note: IP addresses shown on screen are from reserved documentation ranges (RFC 5737).
Narration voice generated with ElevenLabs.