#Why this matters
In the previous lessons, you saw how packets travel between IP addresses and how client applications communicate with servers. Humans, however, do not type 192.0.2.25 to check university grades or open a documentation page. Instead, we type a URL such as https://app.lab.local/login.
Two core systems bridge that gap: DNS turns the hostname into an IP address, and HTTP carries the actual request and response. Both troubleshooting outages and solving entry-level web security (veb-tahlil) challenges start with reading those exchanges directly instead of relying only on what a browser renders on screen.
#Anatomy of a URL
A URL (Uniform Resource Locator) tells a client how to connect, where to connect, and what to ask for. Consider this example:
https://portal.lab.local:8443/courses/intro?page=2#summary
| Part | Value | Role |
|---|---|---|
| Scheme | https |
Protocol (http defaults to port 80; https uses TLS on port 443) |
| Host | portal.lab.local |
Domain name or IP address of the target server |
| Port | 8443 |
Optional TCP port; omitted when using the scheme default |
| Path | /courses/intro |
Specific resource path requested on the server |
| Query | ?page=2 |
Key-value parameters passed to the web application |
| Fragment | #summary |
Client-side section anchor; browsers do not send it to the server |
Notice the fragment rule: anything after # stays inside the browser. If you ever inspect a URL and wonder why the server never saw #section-2, that is by design.
#DNS resolution: names to IP addresses
Before a browser can open a TCP or QUIC connection, it needs an IP address. DNS (Domain Name System) provides this mapping through a hierarchy of nameservers. First your system checks its local cache; if missing, it asks a recursive resolver (often run by your ISP or local network), which walks from root nameservers to the Top-Level Domain (such as .local or .org) down to the domain's authoritative nameserver.
Common DNS record types include:
- A: Maps a hostname to an IPv4 address.
- AAAA: Maps a hostname to an IPv6 address.
- CNAME: Creates an alias from one domain name to another.
- TXT: Stores text metadata, commonly used for domain ownership checks and email security policies.
Classic DNS queries travel over UDP or TCP port 53 in plaintext, though modern systems increasingly encrypt lookups using DNS over HTTPS (DoH) or DNS over TLS (DoT). You can query DNS directly with dig:
$ dig app.lab.local A +noall +answer
app.lab.local. 300 IN A 192.0.2.25Here, 300 is the DNS TTL in seconds (how long resolvers may cache the answer), IN stands for Internet class, A is the record type, and 192.0.2.25 is the resolved IPv4 address.
#How HTTP works
Once the client knows the IP address, it connects and speaks HTTP (Hypertext Transfer Protocol). (While HTTP/2 and HTTP/3 pack messages into binary frames for speed, the request-response model and headers remain the same.)
An HTTP request starts with a method (GET to fetch a resource, POST to submit data, HEAD to fetch headers only), a path, and headers such as Host (essential when one IP hosts multiple sites) and User-Agent.
An HTTP response starts with a three-digit status code, followed by response headers (like Content-Type, Location, or Set-Cookie) and an optional body:
- 2xx (
200 OK): Request succeeded. - 3xx (
301,302): Redirect; check theLocationheader for the new target. - 4xx (
401,403,404): Client error (authentication required, forbidden, or not found). - 5xx (
500,502): Server-side failure while processing the request.
Using curl -i prints both the response headers and the body right in your terminal:
$ curl -i http://app.lab.local/status
HTTP/1.1 200 OK
Server: nginx
Content-Type: application/json
X-Lab-Hint: check-robots-path
Content-Length: 20
{"status":"online"}A browser hides X-Lab-Hint from the rendered page, yet curl -i reveals it immediately.
#Defending and common mistakes
- Leaving internal notes in headers or source: Custom
X-*headers, server version banners, or leftover developer comments are readable by anyone usingcurlor browser DevTools. Strip debug headers before deployment. - Serving sensitive traffic over
http://: Plaintext HTTP exposes paths, headers, session cookies, and form data to anyone on the network path. Always enforcehttps://with TLS 1.2 or TLS 1.3. - Expecting URL fragments on the server: Because
#fragmentvalues stay on the client, server-side access logs and backend code never receive them. - Trusting client-controlled headers: Headers like
HostandUser-Agentcome from the caller and can be forged withcurl -H; validate expected hostnames on the server.
#Summary
- A URL specifies the scheme, host, optional port, path, query parameters, and client-side fragment.
- DNS resolves hostnames to IP addresses using records such as
A,AAAA,CNAME, andTXT, cached according to each record's TTL. - HTTP pairs request methods and headers with response status codes (
2xx,3xx,4xx,5xx), headers, and bodies. - Inspecting raw answers with
digandcurl -iuncovers redirects, headers, and metadata hidden by a browser's visual view.