Skip to the page

Computer networks · core

DNS, HTTPS, cookies and what happens for a URL

When you open a website, DNS finds the address, TCP and TLS set up a safe connection, and cookies carry your login.

The notes

What you must know

  • URL journey: the browser reads the URL and checks its cache; DNS gives the IP; the packet goes to the default gateway (ARP finds the router MAC); TCP handshake on port 443; TLS handshake; the HTTP request; the response is rendered.
  • MAC addresses change at each hop. IP addresses stay the same from end to end.
  • DNS lookup: browser cache, then operating system cache and hosts file, then the resolver (college, ISP or public like 8.8.8.8). If not cached, the resolver asks a root server, then the TLD server (.com, .in), then the authoritative name server.
  • TTL says how long a record may be cached. Record types: A (IPv4), AAAA (IPv6), CNAME (alias).
  • HTTP sends text anyone on the path can read. HTTPS is HTTP inside TLS: encrypted, protected against change, and the server proves its identity with a certificate signed by a certificate authority.
  • With HTTPS an admin on college Wi-Fi can still see the IP, the domain name, the time and the amount of data. They cannot see the path, form data, cookies or page content.
  • HTTP is stateless. A cookie is a small value the browser stores and sends back. A session keeps data on the server, found by a session ID in a cookie.
  • Logged out after refresh: check Set-Cookie in the login response and the Cookie header on the next request. localhost:3000 and localhost:5000 are different origins. A cross-origin fetch sends cookies only with credentials: "include", and the server must allow it.

The red pen

Common traps: mistake → fix

  • Mistake: HTTPS hides which website you visit

    Fix: the domain is still visible.

  • Mistake: HTTPS means the site is safe

    Fix: a phishing site can have a valid certificate.

  • Mistake: DNS is one big server

    Fix: it is a tree of servers with caches.

  • Mistake: Store the password in a cookie

    Fix: store only a session ID.

Easy to hard

Questions interviewers ask, easy to hard

  1. What happens when you type a URL and press Enter?
  2. How does DNS find an address?
  3. What can the college admin see if you use HTTPS?
  4. You are logged out after every refresh in your project. How do you debug?

Practise

Practise with these questions

Explain it out loud

Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.

Practise by voice

Your first interview is free

Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.

Start your free interview