What happens when you visit a Website?

Step 1: DNS - Find the address

If you search github.com, the browser doesn't know where this lives. It uses an IP address that it gets from DNS (Domain Name System). DNS provides a name for every IP on the internet.

bash
dig github.com

Without DNS, you would need to memorize IP addresses for every website.

Step 2: TCP

Now, the browser knows the address but it needs to create a connection before it sends any data. This is the TCP(Transmission Control Protocol) handshake.

You can watch this happen:

bash
curl -v https://github.com 2>&1 | head -30

What each part does:

Look for these lines in the output:

output
*   Trying 140.82.121.3:443...
* Connected to github.com (140.82.121.3) port 443 (#0)

Your computer just performed a TCP handshake with GitHub's server on port 443. The connection is open.

Step 3: TLS

Port 443 means HTTPS — HTTP wrapped in TLS encryption. Before any web data flows, the browser and server perform a TLS handshake for encryption keys.

This is what puts the lock icon in your browser. Without it, anyone on the same Wi-Fi network could read every page you visit, every password you type, every message you send.

In the curl -v output, you'll see the TLS handshake:

output
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
* TLSv1.3 (IN), TLS handshake, Certificate (11):
* TLSv1.3 (IN), TLS handshake, Finished (20):
* TLSv1.3 (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3

What happened here:

Step 4: HTTP — Asking for the Page

Now the encrypted tunnel is open. Your browser asks for the page and the server responds. Run this to see both:

bash
curl -sI https://github.com

Output:

output
HTTP/2 200
content-type: text/html; charset=utf-8

What each line means:

That's it. Your browser receives this, then downloads the full HTML, CSS, and JavaScript to render the page you see.

Why This Matters for Security

Every step is a potential attack surface:

Understanding each layer is understanding where attacks happen and how to defend against them.