Pebellslearn by building
0%
RoadmapsMatrixCoursesSandboxSign in
Learn the Basics  ›  Lesson

TCP/IP and DNS — Reaching the Server

Understand TCP / IP 12 minBefore any API call, DNS turns the host name into an IP address, IP carries packets to it, and TCP turns those packets into a reliable, ordered connection.

TCP/IP and DNS — Reaching the Server

Before the BookNook app can ask for a single book, it has to find the server and open a line to it. Two old, quiet systems do that work on every request: DNS turns the name into an address, and TCP/IP carries the bytes there and back. When an API "is down" but the server is fine, the fault is often in one of these two.

The rule

DNS finds the address; IP delivers the packets; TCP keeps them in order.

DNS (Domain Name System) is the internet's phone book. The app knows the name api.booknook.example, but networks route by number. A DNS lookup returns the number:

$ dig +short api.booknook.example A
203.0.113.10
  • An A record maps a name to an IPv4 address; an AAAA record maps it to an IPv6 address.
  • A CNAME record says "this name is an alias of that name".
  • Each answer has a TTL (time to live): how many seconds resolvers may cache it. A long TTL means a changed address takes longer to reach everyone.

IP (Internet Protocol) moves small packets from one address to another, hop by hop through routers. It does its best, but packets may arrive late, twice, out of order or not at all.

TCP (Transmission Control Protocol) sits on top of IP and turns that unreliable stream of packets into a reliable, ordered conversation. It numbers every byte, re-sends anything lost and opens with a three-step handshake: SYN, SYN-ACK, ACK. A port picks which program on the machine gets the data: 443 for HTTPS, 80 for plain HTTP.

On top of TCP, HTTPS adds TLS encryption, and on top of that runs HTTP, the language of the API itself.

The shortcut

Walk the layers from the name down, then back up: name → address → connection → encryption → request.

The BookNook app asks for book 42Step 1 of 4
  1. Name to address

    DNS resolves api.booknook.example to 203.0.113.10, using a cached answer if the TTL has not run out.

When something fails, the layer tells you who to blame: "could not resolve host" is DNS, "connection refused" or a timeout is TCP or the network, and a 500 error is the API itself.

Drills

Answer fast — trust the rule.

quick drill

What does a DNS lookup for api.booknook.example return?

quick drill

Packets can arrive out of order on the internet. Which protocol puts them back in order for the API?

quick drill

A client error says "could not resolve host api.booknook.example". Where is the problem?

quick drill

BookNook moves to a new server, but some users reach the old address for hours. What most likely explains it?

Remember

  • DNS finds the address; IP delivers packets; TCP keeps them reliable and in order.
  • Shortcut: name → address → connection → encryption → request.
  • Trap: blaming the API for a DNS or network failure; the error message names the layer.

Practice — level up

0/1 solved

Write your answer, then compare it with a rubric and a model answer.

ExplainFrom a name to a request

Describe what happens between the BookNook app deciding to call https://api.booknook.example/v1/books/42 and the HTTP request reaching the server. Then say which layer is at fault if the error reads 'could not resolve host'.