Loading...

Lab 66: Using curl and ping for Network Testing

Validate service availability using layered checks: confirm basic network reachability with ping, then test HTTP behavior using curl. Capture evidence for redirects and header-level status to separate “network down” from “web app down.”

network troubleshooting core

Scenario

A web service is reportedly down. Your job is to test both basic connectivity and HTTP-level behavior for example.com. You will verify ICMP reachability, make an HTTP request, inspect headers only, and then follow an HTTP redirect to confirm the service is accessible over HTTPS.

Operator context

A host can be reachable while the web service is failing, or a web service can be healthy while ICMP is blocked by policy. Use ping and curl together to avoid false conclusions and to produce actionable evidence.

Objective

  • Test basic reachability to example.com using ICMP.
  • Make an HTTP request and capture the response body.
  • Fetch only HTTP headers to confirm status and redirect targets.
  • Follow redirects to validate the HTTPS endpoint.

What You’ll Practice

  • Using ping -c to validate reachability and loss.
  • Using curl to test HTTP connectivity and capture output.
  • Retrieving response headers with curl -I.
  • Following redirects with curl -L.

Walkthrough

Step 1 : Test basic connectivity to example.com.
Command
ping -c 4 example.com

This confirms whether the host responds to ICMP echo requests and provides packet loss and latency signals.

PING example.com (93.184.216.34) 56(84) bytes of data.
64 bytes from 93.184.216.34: icmp_seq=1 ttl=56 time=22.4 ms
64 bytes from 93.184.216.34: icmp_seq=2 ttl=56 time=22.1 ms
64 bytes from 93.184.216.34: icmp_seq=3 ttl=56 time=21.9 ms
64 bytes from 93.184.216.34: icmp_seq=4 ttl=56 time=22.3 ms

--- example.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3006ms
rtt min/avg/max/mdev = 21.900/22.175/22.400/0.199 ms
Step 2 : Make an HTTP request using curl.
Command
curl http://example.com

This tests HTTP connectivity and returns the response body. Many sites redirect plain HTTP to HTTPS, which can appear as a 301 response.

<html>
<head><title>301 Moved Permanently</title></head>
<body>
<center><h1>301 Moved Permanently</h1></center>
<p>Resource has moved to <a href="https://example.com/">https://example.com/</a></p>
</body>
</html>
Step 3 : Fetch headers only to confirm status and redirect target.
Command
curl -I http://example.com

Headers are often enough to validate the HTTP status code, the Location redirect target, and the server’s response metadata.

HTTP/1.1 301 Moved Permanently
Location: https://example.com/
Content-Type: text/html; charset=UTF-8
Content-Length: 162
Date: Thu, 06 Nov 2025 10:15:42 GMT
Server: ECD (example)
Step 4 : Follow redirects from HTTP to HTTPS.
Command
curl -L http://example.com

Following redirects validates the final destination content and confirms that the HTTPS endpoint is reachable and serving responses.

* Redirecting to: https://example.com/
* Successfully fetched via HTTPS
<!doctype html>
<html>
  <head>
    <title>Example Domain</title>
    <meta charset="utf-8" />
    <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
  </head>
  <body>
    <div>
      <h1>Example Domain</h1>
      <p>This domain is for use in illustrative examples in documents. You may use this
      domain in literature without prior coordination or asking for permission.</p>
      <p><a href="https://www.iana.org/domains/example">More information...</a></p>
    </div>
  </body>
</html>

Reference

  • ping -c <N> <host> : Sends N ICMP echo requests to test reachability and loss.
    • Useful for quick confirmation that the target responds to ICMP and for basic latency signals.
  • curl http://<host> : Makes an HTTP request and prints the response body.
    • Common outcomes include 200 success, 301/302 redirects, or 4xx/5xx errors.
  • curl -I http://<host> : Fetches headers only (status line, redirect Location, metadata).
    • Fast way to confirm status without downloading full content.
  • curl -L http://<host> : Follows redirects until the final destination is reached.
    • Useful when services enforce HTTPS or redirect to a canonical hostname.