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.