Ravindra BagaleCourses & study guides मराठी Track your progress

Chapter 4: Linux Advanced Commands

AWS Cloud

4.7 Networking commands

Friends, the website won't open – is the problem in the server or in the network? Collect evidence about the specific listener, HTTP request, and hostname lookup. The three you need most are ss, curl and dig.

Command Purpose Example
ip addr (ip a) Interfaces and IP addresses ip -4 a
ip route Routing table / default gateway ip r
ss -tulnp Inspect TCP listeners and applicable UDP sockets, with process details when accessible. ss -tlnp
netstat -tulnp Older equivalent of ss (package net-tools) netstat -tlnp
ping Send ICMP echo and report replies ping -c 3 127.0.0.1
curl HTTP client — test websites/APIs curl -sS -i --max-time 4 "$lab_url/health"
wget Download files wget --no-proxy -O - "$lab_url/health"
dig / nslookup DNS lookup (package bind-utils or dnsutils) dig example.com A +time=2 +tries=1
traceroute / tracepath Probe an approved path for visible hops Choose a destination on your authorized lab network.
nc (netcat) Test if a TCP port is open nc -zv -w 2 127.0.0.1 "$net_port"
hostnamectl Show hostname information on a systemd host hostnamectl status
# Read-only observations in a Linux lab
ip -br address
ip -4 route get 127.0.0.1
ss -4 -ltn
ping -c 3 127.0.0.1

Reading ss -tlnp output

In an IPv4 listing, 0.0.0.0:80 indicates a wildcard listener, and 127.0.0.1:3000 indicates IPv4 loopback only. A listener can also bind a specific non-loopback address. An external connection still needs a valid network path to the local endpoint.

ping to EC2 fails?

A failed ping describes a missing ICMP echo reply for that test. It does not show whether a particular TCP service responds. Check the relevant protocol on an endpoint you are authorized to test and inspect the effective security group rules only when that boundary is part of the path.

Check which network tools are installed

command -v ip
command -v ss
command -v curl
command -v python3
# Optional DNS utility
command -v dig

Ravindra Bagale's Tip

A process bound to 127.0.0.1:3000 can receive direct IPv4 loopback connections in its network context. External traffic must reach a suitable listener or front end that deliberately forwards requests. Check the local address and the rest of the path separately.

Lab

खालील workshop lab मध्ये IPv4 loopback वर छोटा HTTP server चालवा. ss मध्ये address आणि port तपासा. मग curl ने HTTP response आणि command चा exit status वेगवेगळे नोंदवा.

Turn “the page will not open” into testable questions

The Mauli workshop prints a one-page handover, and it also runs a small web application that tells the next shift whether the worksheet is ready. One student receives a browser error. Another student can open the site from the server. The second observation sounds reassuring, but it does not tell you which address, protocol, port, and path each student used. Reading those values and following the route from the client to the application turns a confusing report into individual tests.

A client is the program making a request. Here it can be a browser or the command-line client curl. A server process receives the request and decides what response to send. An IP address identifies a network endpoint or interface within the relevant network context. A port is a number used by a transport protocol such as TCP to help select the destination socket for a connection. A socket is an operating-system object through which a program communicates. A TCP server commonly opens a socket at an address and port and asks the operating system to listen for incoming connections on it. These terms help you place the evidence each command gives you.

Start the investigation by writing down the actual requested URL. For http://127.0.0.1:8123/health, the scheme is ordinary HTTP, the address is a loopback address, the explicit port is 8123, and the path is /health. An omitted port means the scheme's default, such as 80 for HTTP and 443 for HTTPS. These examples use a fixed port on paper and a dynamically assigned one in the lab. Loopback makes the client and server run in the same local network context. On a laptop, entering a loopback URL sends the request to that laptop, even when another terminal is logged in to an EC2 instance.

The workshop example has four observations to make in order. First, find the source environment and address the client actually uses. Second, find out whether a route and a listening socket exist at the necessary sides of the connection. Third, test the connection and the application response for the exact request. Fourth, when a name is involved, verify how the intended client resolves it. You can start at the most likely point, then work outward. A local check deliberately removes some boundaries so you can learn the behavior of one service before investigating the complete path to it.

QuestionObservationNext distinction
What local addresses exist?ip -br address on LinuxAn address is different from a route or a listening app.
Where would this machine send a packet?ip route get with the specific destinationThe local routing decision says little about arrival at the far end.
Which local endpoint listens?ss with protocol, local port, and state filtersA listener is not yet an HTTP response.
What does a request get back?curl with the intended URL and methodCompare the HTTP response, curl status, and expected content.
Which address does the name identify?Application or system resolver evidence and, separately, a DNS queryCompare the actual lookup context with the intended destination.

This lesson uses terminal commands in a Linux lab, with Python 3 and curl for a harmless local HTTP exercise. The address and socket inspection are Linux-specific. The Python and curl steps can also be practiced on a local Unix-like host with those tools. You need no administrator permissions, ports opened to the internet, firewall edits, or external web traffic. Use the same terminal for the lab and its cleanup because that shell stores the scratch path and the process it starts.

Read the Linux address and route evidence

An interface is a named network attachment of the operating system. Examples can include a virtual Ethernet device, a physical adapter, and loopback. Read a short address view, then show IPv4 addresses with their longer detail. Both commands query local settings without changing them. Interface names and addresses vary by system, so the example below is meant to teach interpretation rather than reproduce your machine's values.

ip -br address
ip -4 address show
ip -4 route show
ip -4 route get 127.0.0.1
lo      UNKNOWN    127.0.0.1/8 ::1/128
eth0    UP         10.24.8.31/24
default via 10.24.8.1 dev eth0
10.24.8.0/24 dev eth0 proto kernel scope link src 10.24.8.31
local 127.0.0.1 dev lo src 127.0.0.1

These are selected example lines from the address and route outputs. The /24 is a prefix length. From an IPv4 address with 32 bits, it identifies the first 24 bits as the network prefix in this example. The shown network address range starts at 10.24.8.0, and a destination in that range matches the illustrated connected route. The default route is the usual fallback when a more specific applicable route is not chosen. In this example it names gateway 10.24.8.1 and device eth0. A gateway here is the next hop that handles traffic to destinations beyond the connected group. The route query to 127.0.0.1 instead names the loopback device and a local source, so it involves no gateway.

Neither the route table listing nor the specific route lookup sends a test request. The latter asks Linux to resolve the routing decision for a destination with the given options. A host with multiple interfaces, policy routing rules, or more than one possible source might choose a route you did not expect. When debugging an approved connection, compare the dev, via, and src parts with the intended interface, gateway when applicable, and local source. A result saying local refers to a destination that this host itself handles in the current network context.

The loopback interface can show an operational state such as UNKNOWN in the brief output even when its ordinary local use works. Read the address and test the intended route or connection before interpreting an unfamiliar label. Another interface can be configured as up even while its external path fails. Each command describes something local. It cannot on its own prove that a remote application can receive or respond to the client's traffic.

To observe ICMP echo on your own machine, use ping -c 3 127.0.0.1. The count limits it to three probes. A reply tells you that this network context handles ICMP echo for the loopback destination. A permission error, lack of reply, or packet loss needs its own interpretation. Ping does not establish a TCP connection or send a request for a web path. On a remote path, echo may be blocked even when the intended TCP application is reachable. Do not change security group rules just to make this local demonstration produce a ping reply.

Start a tiny HTTP service bound only to loopback

To see the difference between a listener and a valid application response, make a service with one known GET route. A GET request for /health returns a success status and the text worksheet ready. A GET for any other path returns a not-found status and a short message. A HEAD request has no handler in this training fixture, so Python's base handler sends a method handling error rather than the response you get from GET. These controlled outcomes allow you to distinguish which part of the request changed.

The following program uses Python's standard library. Read the short program even if you are new to Python. The class defines what happens when a GET arrives. The status value becomes the numeric HTTP status in the response. The body variable holds its bytes. The final lines open port zero on IPv4 loopback. Port zero in a bind request tells the operating system to choose an available port. The server writes that assigned number to a scratch file so each command knows exactly which port to test. None of the read-only network inspections need to target a port guessed from an earlier example.

net_lab=$(mktemp -d) || exit 1
printf 'Lab directory: %s\n' "$net_lab"
cat > "$net_lab/listener.py" <<'PYTHON'
from http.server import BaseHTTPRequestHandler, HTTPServer
from pathlib import Path
import sys

class WorkshopHandler(BaseHTTPRequestHandler):
    def do_GET(self):
        if self.path == "/health":
            status, body = 200, b"worksheet ready\n"
        else:
            status, body = 404, b"no such worksheet route\n"
        self.send_response(status)
        self.send_header("Content-Type", "text/plain; charset=utf-8")
        self.send_header("Content-Length", str(len(body)))
        self.end_headers()
        self.wfile.write(body)

port_file = Path(sys.argv[1])
with HTTPServer(("127.0.0.1", 0), WorkshopHandler) as server:
    candidate = port_file.with_suffix(".next")
    candidate.write_text(str(server.server_port) + "\n", encoding="ascii")
    candidate.replace(port_file)
    server.serve_forever()
PYTHON
python3 -u "$net_lab/listener.py" "$net_lab/port.txt" > "$net_lab/server.log" 2>&1 &
net_pid=$!
for attempt in {1..20}; do
  [ -s "$net_lab/port.txt" ] && break
  kill -0 "$net_pid" 2>/dev/null || break
  sleep 0.1
done
if [ -s "$net_lab/port.txt" ]; then
  net_port=$(cat "$net_lab/port.txt")
  printf 'Lab listener is 127.0.0.1:%s\n' "$net_port"
else
  printf 'Listener did not report a port. Read %s/server.log\n' "$net_lab" >&2
fi

Expect the shell to print the scratch directory and a loopback listener with a numeric port. The port varies. The final ampersand on the Python command starts it in the background so the prompt can return. $! is the process ID of that background command. Save it immediately, as shown, so cleanup can address just the program we started. Inside the loop kill -0 checks whether the process can be signaled without sending a signal. The bounded wait checks the newly written port file for about two seconds. The server writes through a temporary file and renames it when the complete port number is ready.

If the port was not printed, stop before running requests and read the log. An unavailable Python interpreter or failure opening the listener would be described there. If the process is still running but the port is unavailable, run the cleanup for this exercise and retry in a new scratch folder. The service is intended only for these known local requests. Python's built-in HTTP server is convenient here because it is available without an installed web stack, and a production web service needs a deployment approach appropriate to its requirements.

Confirm the listening address and protocol

On Linux, ss lets you read the operating system's socket information. The line below asks for listening TCP sockets in IPv4, keeps numbers rather than resolving service names, and includes process information where your account can see it. Its final filter selects the local port matching the one the Python server published. Replace the variable only if you intentionally reused another known lab port. Asking the socket utility directly for the port avoids accidental text matches in an unrelated column.

ss -4 -ltnp "sport = :$net_port"
State   Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN  0      5      127.0.0.1:8123     0.0.0.0:*       users:(("python3",pid=...))

The port 8123 and queue values above are illustrative. Read your actual socket's local address and port. The flags are IPv4 with -4, listening with -l, TCP with -t, numeric display with -n, and available process information with -p. The local address is the important boundary here. The all-address indicator in the peer column of a listening socket does not mean that the socket is reachable at every local address. It has no established single peer before a connection is handled.

The listener in this exercise is bound to 127.0.0.1, so normal traffic sent to the machine's other IPv4 addresses does not reach that socket directly. A listener specifically bound to a machine's non-loopback address can receive traffic for that address if the rest of the path permits it. A local address of 0.0.0.0 on an IPv4 listener indicates a wildcard binding to applicable local interfaces, rather than one particular address. IPv6 can show forms such as [::] and [::1]. Inspect the correct address family, because IPv6 wildcard behavior with IPv4 traffic depends on socket settings and operating system policy.

The listening TCP checks do not describe UDP. UDP has no TCP-style connection establishment, and a UDP socket can appear in a listing with a different state such as UNCONN. Use ss -lun to inspect applicable local UDP sockets separately. Whether an application can exchange UDP datagrams is tested with its application protocol. A TCP connect check to the same number would probe an entirely different type of socket. Likewise, on a system using network namespaces, the same numeric address and port can exist in different network contexts. Run the observation in the environment that actually owns the service.

Some ordinary users cannot see process details for sockets that belong to other users. A missing process field does not erase the rest of the socket observation. For the workshop service you expect to see your own process if supported, and you also saved its process ID in your shell. If the listener row is missing, confirm that the server process is alive and that the port received from its file is current. If an unrelated row appears, check for the exact IP family, address, and owning process before drawing a conclusion. This lab provides a record of all three.

Send the exact request and inspect its response

The socket listing says something is listening at the expected local address and port. Curl tests the application request. We know the scheme is HTTP and the route accepts GET. Build the URL from the loopback address and generated port, then ask Curl to display response headers and body. The -q first argument disables any default curl configuration file for this lab. The explicit --noproxy '*' bypasses configured proxies for the local fixture. A short connection timeout and total time limit bound the test if the server stops answering.

lab_url="http://127.0.0.1:$net_port"
curl -q --noproxy '*' --connect-timeout 2 --max-time 4 -sS -i "$lab_url/health"
HTTP/1.0 200 OK
Content-Type: text/plain; charset=utf-8
Content-Length: 16

worksheet ready

Additional headers such as Server and Date can appear. The status line reports the protocol version, numeric status, and a short phrase in this fixture. The headers convey metadata about the response; the blank line separates them from the content body. The displayed content length includes the newline after ready. The response body confirms that the expected route ran and not just that some service accepted a connection. -sS suppresses the progress display while keeping curl's error messages. -i includes response headers with the body. Without -i, ordinary output would show the body only.

A reason to reproduce the exact method is that a terminal check can otherwise ask a different question from the browser. By default curl uses GET for this URL. With -I, it requests HEAD, a method intended to request header information without a response body. Our sample implements GET only. Run both the wrong-path GET and HEAD on the valid path. The response status can differ even though there is still a working TCP connection to the same process. That gives two ways an application-level test can fail after transport succeeds.

curl -q --noproxy '*' --connect-timeout 2 --max-time 4 -sS -i "$lab_url/missing"
curl -q --noproxy '*' --connect-timeout 2 --max-time 4 -sS -I "$lab_url/health"
HTTP/1.0 404 Not Found
...
no such worksheet route

HTTP/1.0 501 Unsupported method ('HEAD')
...

The dots represent omitted headers. Both requests reached the program. The first selected a path the training application does not serve and returned its named missing-route message. The second selected a method this simple handler never implemented. It returned an HTTP error for that method. A real framework might respond to HEAD with the GET route's headers, or might return another method-related status. Read the exact request and response when comparing curl with a browser. Do not infer that a successful GET has failed simply because a different request was rejected.

Curl's exit status is also separate from HTTP's status. Easy-to-read response status output can be useful for comparing routes. Use -o /dev/null to set aside the body and the -w format to print a selected value afterward. If you need the body to verify application-level success, make that distinct check. The first command below receives the expected 404 and can still return a status of zero under curl's normal behavior. The second uses -f to treat an HTTP error response in this case as command failure.

curl -q --noproxy '*' --connect-timeout 2 --max-time 4 -sS \
  -o /dev/null -w 'response=%{http_code}\n' "$lab_url/missing"
printf 'curl status=%s\n' "$?"
if curl -q --noproxy '*' --connect-timeout 2 --max-time 4 -fsS \
  -o /dev/null -w 'response=%{http_code}\n' "$lab_url/missing"; then
  printf 'Unexpected success\n'
else
  printf 'curl status with fail option=%s\n' "$?"
fi
response=404
curl status=0
response=404
curl status with fail option=22

The second curl also writes a diagnostic to stderr. Its ordering relative to the formatted stdout can vary in a combined display. Status 22 here is the curl code for the HTTP failure condition, while 404 is the server's status. Save the executable's status immediately. Reading a file or printing another message first can replace the previous value. A browser has its own presentation rules, so a general error banner may conceal the difference between finding no responder and receiving a specific application error code.

A TCP-only connect test can be appropriate when the protocol is unknown or when checking the exact transport question before testing the application. If your installed netcat supports these options, nc -zv -w 2 127.0.0.1 "$net_port" attempts a bounded connection to this known local fixture. Flags differ across implementations, so check their local help. Success means the TCP connection was established and does not prove the server returned the correct page. Unlike a curl request, this test does not ask for /health. It cannot tell whether a missing route is fixed.

Find out where the client gets an address

A hostname lets people refer to a service without memorizing its IP address. The system resolver is the software path an application can use to turn a name into an address. On Linux its configured sources can include the /etc/hosts file, DNS, and other services, with the order controlled by system settings. Operationally this means that a DNS query and an application lookup may return different information for the same name. The command you choose should match which behavior you are investigating.

On a glibc-based Linux system, getent ahostsv4 localhost queries the configured host lookup path for IPv4 results. It often prints 127.0.0.1 and may repeat the address with several socket types. Do not treat the repetitions as different IP addresses. On another system a different command may be appropriate. This example uses localhost just to observe the name lookup mechanism. Curl with the literal loopback address has no need to find a DNS address for that host.

For DNS evidence, if the optional BIND utility is installed and the lab has an approved resolver, dig example.com A +time=2 +tries=1 asks for IPv4 address records and shows response details. This is an optional query to your configured DNS service for the IANA example name. It does not require a particular answer from the internet for the loopback lab. Read the DNS status, which resolver replied, and the answer section. An AAAA query asks for IPv6 address records. Records can legitimately change or vary according to the resolver and network environment, so focus the exercise on correctly identifying the query and response fields.

An answer with NOERROR and no A records is a different observation from NXDOMAIN, which reports that the requested name does not exist in the response's view. A timeout provides no such DNS status from a reply. Retaining the full output at first helps distinguish those results. A concise answer view such as +short is useful once you already know the response context, but an empty answer display cannot explain why it was empty. Do not jump from a blank line to a conclusion about whether an HTTP server exists.

For a concrete demonstration without asking DNS to change, use curl's --resolve with a fictional reserved testing name. It tells curl to use the supplied address for the named host and port for this invocation. The request still identifies the hostname in the URL. That distinction matters for web servers with several sites sharing one address, which can use the HTTP host information to select the site. For TLS, the hostname also matters to the protocol and certificate validation. This plain HTTP fixture does not model the TLS portions of an HTTPS connection.

curl -q --noproxy '*' --connect-timeout 2 --max-time 4 -fsS \
  --resolve "workshop.example.test:$net_port:127.0.0.1" \
  "http://workshop.example.test:$net_port/health"
worksheet ready

The server responds because this known host and port are mapped to its loopback address for the one request. No DNS or hosts file was edited. This evidence tells you the endpoint can answer when curl uses that address and host. It does not establish what an unmodified lookup would return. A real app could also run through a proxy which resolves names in another environment. Separate hostname selection, name resolution, and transport evidence when a direct-address check works but a named request fails.

Relate local evidence to the path through an EC2 deployment

The loopback fixture is a model of an application kept behind a front end. A reverse proxy is a service that accepts requests from clients and forwards selected ones to a service behind it. In one deployment the reverse proxy listens on the intended network interface at port 443, terminates TLS, and forwards a request over local HTTP to another process listening at 127.0.0.1 on a higher port. The backend can be healthy without having any reason to listen on an external interface. A public-facing test must exercise the proxy endpoint and request the intended site name. A local backend test answers a narrower question.

In this scenario three different endpoints may be relevant. On the backend's host, a loopback test can show whether the backend returns its expected response. A test to the local proxy's configured listener can show what the proxy does with the intended host and path. A test from an authorized client outside the server can exercise the route reaching the public-facing front end. Avoid mixing their results. A connection to a proxy's address does not imply a direct connection to the backend port. A successful backend response does not establish that the proxy knows where to forward that same route.

On AWS, security groups are stateful network controls for the interfaces associated with them. Their inbound rules describe allowed protocols, ports as applicable, and sources. The backend might be reached only through an interface or local path that never needs a public inbound rule. A subnet route table determines available routes. For a public IPv4 EC2 path, an internet gateway route and appropriate public addressing can be part of the setup. A network ACL at the subnet boundary, a host-level firewall, the listener binding, and the return path may also matter. Verify each point against the actual topology. An allowed security group rule does not create a listener or fix an application path.

When you see a wildcard local bind, it indicates the program is willing to receive traffic addressed to applicable interfaces. Reachability still depends on the actual addresses, paths, and controls in front of them. Conversely, a listener bound to one particular non-loopback address can serve outside clients for that address when the connection can reach it. The workshop exercise keeps its listener on loopback. Allowing a new port inbound would not change its local binding and would unnecessarily expand the intended test's scope. Work with the deployment topology rather than changing every boundary at once.

If an approved remote client times out, collect the actual source and destination and the stage of the timeout. A connection timeout can reflect packets silently discarded anywhere along the path or no usable network route. An application read timeout after a successful connection is another clue. A refusal often indicates an active rejection or no listener at that endpoint, but a firewall or proxy can also participate. A request returning HTTP 404 establishes that an HTTP responder supplied that status. That responder could be a proxy or a different virtual host. Avoid treating all failures as a single verdict about the instance. Note what reached an identifiable point, then choose a test for the next point.

On an authorized path, a route display or a traceroute-style tool can offer different evidence. The host's ip route get reports its own route decision before sending anything. tracepath isn't a passive display of the local table. It sends probe traffic and can report discovered hops and path MTU information when replies are available. Path MTU concerns the packet size a path can carry without requiring special handling. Hops can omit replies even while forwarding other traffic. Do not identify a blocking device from a missing hop alone. For this lesson the loopback HTTP checks and local routing lookup are sufficient, while a planned path investigation on a real network needs the actual approved destinations.

Compare a known listener with the same endpoint after it stops

Before the stop, read the service log in the scratch directory. An ordinary sequence will include GET for the health route, GET for the missing route, and HEAD for the health route. The timestamps and port numbers vary. The server can log more than once for a request when it emits a diagnostic and an access entry. Look for the status and method associated with the test you actually ran. This is an application log made by the fixture, separate from the command status at the client.

cat "$net_lab/server.log"
jobs -l

The job listing is a shell-level observation. If the Python job is alive, its process line should have the same PID stored in net_pid and refer to the scratch listener. Inspect that identity before stopping it. If you have left the terminal that launched the process, do not guess the PID from old text. The next commands use only a running job listed by this same shell and matching the stored process ID. They assume you are still in the launching shell. A saved PID alone is not a permanent identity if a process already ended and the operating system has reused the number.

if jobs -pr | grep -Fxq "$net_pid"; then
  kill "$net_pid"
fi
wait "$net_pid" 2>/dev/null || :
if curl -q --noproxy '*' --connect-timeout 2 --max-time 4 -fsS \
  -o /dev/null -w 'response=%{http_code}\n' "$lab_url/health"; then
  printf 'A service still answered on the port. Inspect it before cleanup.\n'
else
  printf 'curl status after lab stop=%s\n' "$?"
fi
response=000
curl status after lab stop=7

The response value 000 is curl's display when it has no HTTP response code in this failure. It is not an HTTP status transmitted by a server. The expected curl code 7 here reports that the client could not connect. A connection diagnostic is also printed, and its wording can vary. If a listener is still shown, check whether your original lab process is gone or another process has since selected the same port. This exercise relies on a short time window and a uniquely chosen local port. Never stop any other process just to make the expected result appear.

Compare this failed connection with the earlier application errors. In the earlier case, the socket was listening and the server could use HTTP to report a missing path or method. After stopping it there is no expected responder to supply any HTTP status. The URL and address stayed the same. By changing only the presence of the server we have an explanation for the different results. Use the same technique when testing changes in a real lab: change one component, preserve the request, and recheck the observation that the change is meant to affect.

After the final check, confirm the directory belongs to this exercise. The resulting files contain only the test program, generated port, and local messages. The cleanup removes known names and the empty directory. If you added your own capture, move it to a desired location or remove its exact path separately. No network settings or AWS rules were changed in the exercises.

if [ -n "${net_pid:-}" ] && jobs -pr | grep -Fxq "$net_pid"; then
  kill "$net_pid"
  wait "$net_pid" 2>/dev/null || :
fi
if [ -n "${net_lab:-}" ] && [ -d "$net_lab" ]; then
  printf 'Removing network fixtures from %s\n' "$net_lab"
  rm -f -- "$net_lab/listener.py" "$net_lab/port.txt" "$net_lab/port.next" "$net_lab/server.log"
  rmdir -- "$net_lab"
fi
unset net_lab net_pid net_port lab_url attempt

Record evidence a second person can reproduce

Before stopping the fixture, make a handover note with an address, a port, an HTTP method, a path, and an expected result. Use the generated port and the Linux socket observation where available. One correct note will say that the service is bound to IPv4 loopback and that the exact GET request for the health route returns a 200 status with the words worksheet ready. Include curl's executable status and the server's HTTP status as separate fields. The note should be enough to guide a second person using the same lab terminal. It should also say that a request from another machine to its own loopback address cannot reach this process.

For the first exercise, ask a classmate to choose one change to the request, either a different path or HEAD instead of GET. Keep the local address and port fixed. Predict which kinds of evidence should stay the same. The listener should still be there, and the path lookup from the same host should still indicate loopback. The expected application result changes to 404 for an absent route and 501 for this fixture's unsupported method. Record whether Curl treats the HTTP status as an executable failure with the options you used. Review the server's log afterward and match each request to its response.

For the second exercise, save the known health response as data while the service is available. Use a new scratch filename and inspect the bytes afterward. In an approved downloading workflow, tools like curl or wget can write responses to disk. The fact that a file path was created is not evidence that the correct bytes landed there. The following practice uses curl with a status check and compares the one-line content with a prediction. Run it before the stop exercise, or start a fresh fixture if you already removed the first one. The cleanup at the end of this block removes just its optional files.

printf 'worksheet ready\n' > "$net_lab/body.expected.txt"
if curl -q --noproxy '*' --connect-timeout 2 --max-time 4 -fsS \
  -o "$net_lab/body.received.txt" "$lab_url/health" \
  && cmp "$net_lab/body.expected.txt" "$net_lab/body.received.txt"; then
  printf 'Saved response matches expected bytes\n'
else
  printf 'Check the request error or response body\n' >&2
fi
rm -f -- "$net_lab/body.expected.txt" "$net_lab/body.received.txt"
Saved response matches expected bytes

Using a path you created under the lab directory also makes the cleanup safe. Saving a response changes how you see the result, because the displayed terminal output may contain no body at all. A successful exit plus equality with the expected data supports the conclusion for this fixture. A request to a different server might produce a successful status and different content. That gives you a way to reason about a production service that serves a generic proxy default page with a successful status. Check the actual intended response before reporting that the content is healthy.

For the third exercise, sketch the workshop reverse-proxy scenario and label four points: client, public proxy listener, loopback backend, and the expected handler. Next to each point, name one observation that would identify it. A resolver answer helps identify a client destination but cannot tell you which application route the proxy selected. A listener row identifies a local endpoint and sometimes a process. An HTTP response plus application log helps identify how the request was handled. In a scenario with an external access problem, state which observation in your sketch is still missing before proposing a change.

If you get a result that differs from the examples, check the test assumptions first. Did the same shell store the current port? Did the test URL explicitly use IPv4 loopback, or did a hostname resolve to IPv6? Is the request attempting plain HTTP while the service expects TLS? Does the method match? Is the connection going through a proxy configured by your environment? Reading the exact error often identifies one branch. The lab disables proxies to make that boundary simple, but networks used by organizations can require an approved proxy for external requests. Work with the network's documented configuration when reproducing that path.

For one extra observation, compare a destination with an address family the listener does not use. The lab starts an IPv4 socket, and 127.0.0.1 is its exact destination. An IPv6 URL writes an address like loopback in brackets, since colons are already part of the address. The example form is http://[::1]:8123/health with your own lab port in place of the illustrated value. Even if your machine has IPv6 loopback available, an IPv6 connection to that address is not handled by the IPv4-only fixture. A completely different process could happen to listen on that IPv6 port, so first consult a socket listing and do not assume a response there came from this program. The exercise explains why using localhost in one test and a literal IPv4 address in another can change the results.

Explain what each result proves

Interview question. The listener shows 127.0.0.1 and an inbound rule allows the same port. Why does a browser on your laptop fail?

The listener is bound to the server's loopback address, so incoming traffic addressed to a different server interface cannot reach it directly. The inbound rule controls a network boundary and does not change the socket's address. Determine how the application is supposed to be reached. A separate proxy on a permitted listener can forward to a loopback backend when the deployment is designed that way.

Interview question. What is the difference between a DNS answer, a route, and an HTTP success?

A DNS answer tells you which records a resolver returned for the name and type. A route describes how the local host chooses to send traffic toward a destination. An HTTP success identifies a response to a specific request, and the content helps verify the intended service. Record the name, actual endpoint, and request so those observations can be related.

Quiz. You get a local TCP connection and an HTTP 404 for a known wrong path. Which check should change next?

Keep the known endpoint and use the correct method and path. A connection and HTTP response were observed. An HTTP route selection can fail with the port still open, so inspect the response and application before changing any network rules.

Quiz. Curl printed response 000 after the training server stopped. Which HTTP status did it receive?

It did not receive an HTTP status. The formatted value reflects the absence of a response code. Read curl's nonzero command status and accompanying connection diagnostic, then check whether the expected socket is still present.

Quiz. A ping gets no reply. What should you test if the report is about an HTTPS page?

Use the exact approved HTTPS hostname, port, and path from the relevant client environment and inspect the connection, TLS and HTTP responses. ICMP echo is a separate protocol. Its absence can be consistent with a healthy TCP application.

Revision cards

Local addresses and listening sockets

Use address and route information to learn where the host is configured to send traffic. Use a socket listing to observe the expected application's local address and protocol.

One request, two kinds of status

HTTP status is reported by a responder. Curl's exit status describes running the command with its options. Keep both and inspect the expected content.

Identify which path was tested

Loopback, an internal proxy route, and a public client request exercise different paths. Write down where the client ran and which address, host, method and path it used.

Primary references