LinuxTutorial2 min read

How to Test Network Connectivity on Linux

Diagnose network problems on Linux using ping, traceroute, curl, and wget — practical commands for checking connections and downloading files.

Developer terminal on a laptop in low light

Why Test Network Connectivity?

Network issues are common on Linux servers. A methodical approach — testing from your machine outward — helps you quickly pinpoint whether the problem is DNS, routing, firewall, or the remote host.

ping — Is the Host Reachable?

ping sends ICMP echo packets to a host and reports round-trip time:

ping google.com              # ping forever (Ctrl+C to stop)
ping -c 4 google.com         # send exactly 4 packets
ping -c 4 8.8.8.8            # ping by IP (bypasses DNS)

If ping 8.8.8.8 works but ping google.com fails, the issue is DNS resolution, not internet connectivity.

traceroute — See the Network Path

traceroute shows every router hop between you and the destination:

traceroute google.com
# Install if missing:
sudo apt install traceroute

Look for where hops stop responding — that's usually where the problem is. A * * * means a router isn't responding to probes (common and not always a sign of a problem).

curl — Test HTTP/HTTPS Endpoints

curl is the go-to tool for testing web servers and APIs:

curl https://example.com                    # fetch a URL
curl -I https://example.com                 # headers only (check status code)
curl -v https://example.com                 # verbose: show full request/response
curl -o output.html https://example.com     # save response to a file
curl -L https://example.com                 # follow redirects

The -I flag is great for quickly checking if a site is up and what HTTP status code it returns.

wget — Download Files

wget is designed for downloading files, including handling retries and resuming interrupted downloads:

wget https://example.com/file.tar.gz         # download a file
wget -c https://example.com/bigfile.iso      # resume a partial download
wget -q https://example.com/script.sh       # quiet mode

Checking DNS Resolution

nslookup google.com
dig google.com
host google.com

If DNS fails, try using a public resolver directly: ping 8.8.8.8 (Google) or ping 1.1.1.1 (Cloudflare).

Quick Connectivity Checklist

  1. ping 8.8.8.8 — confirms basic internet access
  2. ping google.com — confirms DNS works
  3. curl -I https://yoursite.com — confirms HTTP is reachable
  4. traceroute yoursite.com — find where packets are dropping