Read Your Own Pod's Network
Goal
Networking does not stick when you learn it from diagrams. You will read the network of the Pod you are using right now yourself, and at the end you take a single report that "the site won't open", work out which layer the problem belongs to, and fix it.
This is not an example made for a textbook but a real production cluster, so things that never appear in books show up as they are: a /32 address, a path MTU that differs from the interface's, and search domains.
Why it matters
Outage reports always arrive in the user's words. "It won't open" may mean the name could not be resolved, that nobody is listening on that port, or that the certificate's name is wrong. The three look identical in a browser, but the places to fix are completely different. The reason you read this Pod's addresses, routes, names, and ports yourself in the earlier steps is so that in the final incident you can read them as evidence.
Where to look
| What | Where |
|---|---|
| My address | ip -4 addr |
| Where traffic goes out | ip route, ip route get <목적지> (destination) |
| Interface MTU | /sys/class/net/<인터페이스>/ (interface) |
| How names are resolved | /etc/resolv.conf, getent hosts |
| Current connection and listening state | ss |
Steps
- This Pod's IP and netmask, and what they mean →
01-addr.txt - The routing table, and why it reaches the gateway even with a
/32→02-route.txt - The interface MTU and the default route's MTU, and why they differ →
03-mtu.txt resolv.confand the actual lookup result for one short name →04-dns.txt- Start a server on 8080 and one more on the same port, and that error →
05-port.txt - An HTTP request written by hand and the response received →
06-http.txt - State changes seen while creating and closing connections (including
TIME-WAIT) →07-states.txt - Incident
nw-site-down: reopen the three sites and record a layer code for each site in/root/incident/nw-site-down/report.txt
Notes
- This Pod cannot reach the outside Internet. Only DNS lookups are open. So do all the experiments against a server inside this Pod. You still learn everything there is to learn.
- Create the files for steps 1–7 in
/root(where the terminal first opens). - Incident tools:
incident listfor the list,incident nw-site-downto raise the incident, andincident show nw-site-downto see the report again. Raising it again returns it to its original broken state. - Report format: one line
<사이트>: <코드>(site: code) per site, plusevidence: <관찰한 출력 한 줄>(one line of output you observed). /etc/hostsis a bind mount, sosed -ifails (it cannot swap in a new file). Fix it with an editor.
My address and netmask
Check this Pod's IP and netmask and save them to 01-addr.txt, and write one line on what that netmask means.
Use ip -4 addr show eth0. You should see /32.
/32 means I am alone on this network. Normally, as with /24, there are neighbors in the same range, but here there are none. How it gets out to the outside is the next step.
But how does it get out
Extract the routing table and save it to 02-route.txt, and write why it can reach the gateway even though it is a /32.
Use ip route. You should see two lines: default via <게이트웨이> and <게이트웨이> dev eth0 scope link (the gateway address goes where the Korean word is).
The second line is the answer. It tells the kernel that that address is reachable directly without routing (on-link). By the netmask it is not in the same range, but because this route exists, it can reach the gateway.
The MTU of the interface and the path differ
Check the MTU of eth0 and the MTU of the default route separately and save them to 03-mtu.txt. If they differ, write why as well.
The interface's value is in a file in that interface's folder under /sys/class/net/, and the value for going to a specific destination appears in the mtu field at the end of the output of ip route get <바깥 주소> (an outside address); the route can be computed even if you cannot get out.
If the two values differ, think about what takes bytes in between: this cluster connects nodes with an encrypted tunnel. When the MTU is mismatched, the symptom is that small requests work but only large responses stall.
How a short name gets resolved
Look at /etc/resolv.conf, actually look up one short name, and save it to 04-dns.txt.
cat /etc/resolv.conf has nameserver and search. Look up a short name such as getent hosts kubernetes.default.
The domains listed in search are tried appended in order. Like this: kubernetes.default → kubernetes.default.<네임스페이스>.svc.cluster.local → … (the namespace goes where the Korean word is). That is why it is found even when written short.
One program per port
Start a server on port 8080, then try to start one more on the same port, and save the error that appears to 05-port.txt.
Start one server on 127.0.0.1:8080 with Python's http.server module and leave it running (send it to the background), then try starting a second server on the same address and port, or try a bind with Python's socket. Record the error message that appears exactly as it is.
Only one socket at a time can hold an address+port combination. This is what is really behind the deployment accident where a new version cannot start because the "port is already in use".
Type HTTP by hand
Without a library, write the HTTP request string yourself over a TCP connection, receive the response, and save it to 06-http.txt.
In bash, opening /dev/tcp/<주소>/<포트> (address, port) gives you a TCP connection (Python's socket works too). Write the request line (GET / HTTP/1.1), the Host header, and Connection: close to that connection, then read what comes back.
Line endings must be \r\n, and there must be one more blank line at the end of the headers; without that blank line, the server thinks the request has not ended yet and keeps waiting. Record both what you sent and what you received.
Connections have states
While creating and closing a connection, watch with ss how the state changes and save it to 07-states.txt. TIME-WAIT must be visible.
Look with ss -tan. While connected it is ESTAB, and after closing, TIME-WAIT remains for a while.
TIME-WAIT is not a bug. It holds the slot for a moment so that late-arriving packets do not get mixed into the next connection. If these pile up on a server that creates many short connections, ports run dry, which is why connections are reused (keep-alive).
Incident: three sites fail to open in the same way
Running incident nw-site-down makes three internal sites, https://shop.nw.test/, https://api.nw.test/, and https://pay.nw.test/, all show the same "can't connect" in the browser. The symptom is the same, but the cause for each site lies in a different layer. Make all three open again with curl without turning off certificate verification: the site configuration is in /etc/nw-sites/<shop|api|pay>.conf, and restarting is nw-site restart <shop|api|pay>. Turning off verification or starting a different server at that address is not a fix.
Then, in /root/incident/nw-site-down/report.txt, write one line <사이트>: <코드> (site: code) per site (three lines) and evidence: <관찰한 출력 한 줄> (one line of output you observed). Pick the codes from four layers: application (a response comes back but the status code or content is wrong), name (the name does not resolve to an address), security (it connects but breaks at the TLS check), transport (no TCP connection to that address and port).
Direction: do not treat "won't open" as one lump; in the order a request goes through (name → TCP connection → TLS → HTTP), ask separately how far each site got. Even if the same person touched them on the same day, the place where each stopped can differ.
Tools: curl -v (shows line by line how far it got), getent (resolves names along the same path as the application), ss (who is waiting on which address and port), openssl (decodes certificate files into human-readable form).
Concretely: an error line has the form "number + description". Read whether the description after the number says the name could not be resolved, that it could not connect to the server, or that it is about the certificate. If the name does not resolve, check whether this Pod's name table file has a line similar to that name (that file is a bind mount, so tools that swap in a new file, like sed -i, fail). If it cannot connect, compare the port the address actually listens on, from the Local Address:Port field of the list of listening sockets, with listen in the site configuration. For a certificate error, consider whether the SAN (the list of names written in the certificate) of the certificate the server presented matches the name you connected to, and where that certificate came from; what you need to fix is the configuration, so that it uses a certificate signed by the internal CA. After changing the configuration, you must restart for it to take effect.