ch07/l02

DNS, sockets, and HTTP are separate

Distinguish name resolution, listening sockets, and application responses.

curl -I 25 min read, 35 min lab operator

DNS resolution can succeed while the port is closed. A port can listen while HTTP returns an error. `dig`, `ss`, and `curl` prove different things.

In the field

A URL is failing. You need to determine whether DNS, socket binding, or HTTP response is the first failure.

Worked command

$ dig +short terminaldrill.com$ ss -tulpn$ curl -I https://terminaldrill.com$ curl -v http://127.0.0.1:8080/
Anti-pattern

Do not treat one green check as proof of the whole path.

Safer pattern

Resolve name, check socket, then test protocol response.

Knowledge check

`dig +short` returns an address and `ss -tulpn` shows the port listening, but `curl -I` returns 502. Which layer is the first failure?

  • A DNS resolution failed
  • B Nothing is bound to the port
  • C The HTTP layer: name and socket are fine, the server returned an error response
  • D The default route is missing
Show the answer

Correct: C. The HTTP layer: name and socket are fine, the server returned an error response

Why

DNS resolved and the socket is listening, so those layers passed; a 502 is the server answering with an application-layer error. Treating one green check as proof of the whole path is the conflation to avoid.

Practice checklist

  1. Resolve a domain.
  2. Inspect local listening sockets.
  3. Fetch headers from a known URL.

Deliverable evidence

  • DNS result, socket evidence, HTTP header result.
Teaching diagramch07 · mental model
walk the symptom down the ladderaddress + routeip addr / ip routename (DNS)dig +shortsocketss -tulpnHTTP responsecurl -I / -veach step proves ONE layergreen here does not prove green therefirewallfirewall-cmd --list-allaudit before editruntime vs permanentping reaching a host does not prove the application answers

shows: The diagnostic ladder for a reachability symptom: address and route, then DNS name resolution, then listening socket, then HTTP response, with firewall audited separately, and each command proving only its own layer.

does not prove: It does not prove the failure is single-layer: more than one layer can be broken at once, and a green check at one step is evidence for that step only, not proof the whole path works.

Memorize this

Commit these to memory, then drill them until recall is automatic.

dig +shortss -tulpncurl -Icurl -v
Recall practice · Meaning -> command

cue Request only the response headers from an HTTP server to test the protocol layer without downloading the body

show recall target

curl -I