🧠 Introduction

Linux provides powerful, modular tools for diagnosing network issues. Rather than bundling everything into a single command, Linux gives sysadmins a variety of highly focused utilities, each perfect for a different aspect of network testing: connectivity, port access, routing, interface binding, latency, and more.

This guide is a deep-dive into the practical use of those tools, offering examples, scripts, and real-world sysadmin tips.


🛠 Core Tools You Will Use

ToolPurpose
pingBasic reachability and latency
traceroutePath discovery and hop tracking
nc (netcat)TCP/UDP port testing
mtrLive route monitoring with stats
curlHTTP/S endpoint test & header tracing
ssCheck open/listening ports
ip, ip route getInterface binding/testing
nmapService and port scanning
telnetLegacy TCP check fallback

1. ✅ Basic Reachability Test

ping -c 4 google.com
  • -c 4: Send 4 packets
  • Output includes latency, packet loss

Also test raw IPs:

ping -c 4 8.8.8.8

2. 🌐 Tracing the Network Path

traceroute google.com
  • Add -n to skip DNS for faster output
  • Add -m 20 to limit max hops

Alternative:

mtr -rwzbc 50 google.com
  • Real-time hop analysis with loss and jitter

3. 🔌 TCP Port Test (Reachability)

nc -zv example.com 443
  • -z: Zero I/O mode
  • -v: Verbose

To test multiple ports:

nc -zv example.com 22 80 443

Or with timeout:

nc -zvw5 example.com 25

4. 🌍 Testing via Interface or Source IP

ip a

Find your IP or interface name, then:

curl --interface eth0 https://example.com

With netcat:

nc -s 192.168.0.10 -zv example.com 22

5. 🔍 Inspect HTTP/TLS with curl

curl -v --connect-timeout 5 https://example.com
  • Check DNS, TLS, headers, redirects

Headers only:

curl -I https://example.com

Send custom Host header:

curl -H "Host: example.com" https://1.2.3.4

6. 🔎 Local Listening Ports

ss -tuln
  • Shows listening TCP/UDP ports

Active connections:

ss -tnp

7. 📦 Port Scanning with nmap

nmap -p 22,80,443 example.com

Service version detection:

nmap -sV example.com

Full network scan:

nmap -Pn 192.168.1.0/24

8. 🌐 IPv4 and IPv6 Testing

IPv4:

ping -c 4 1.1.1.1

IPv6:

ping6 -c 4 2606:4700:4700::1111

Curl IPv6:

curl -g -6 http://[2606:4700:4700::1111]

9. 🧰 Bulk Port Testing Script

#!/bin/bash
servers=("google.com" "example.com" "192.168.1.1")
port=443

for server in "${servers[@]}"; do
  if nc -z -w3 "$server" "$port"; then
    echo "[OK] $server port $port reachable"
  else
    echo "[FAIL] $server port $port unreachable"
  fi
done

10. 🧭 Diagnose Latency

mtr -rwzbc 100 mysite.com

Graph:


11. 📡 Check DNS with dig/host

dig example.com
host example.com

12. 🔁 Trace Outgoing Interface

ip route get 1.1.1.1
  • Shows which interface/IP would be used to reach 1.1.1.1

13. 🧪 Legacy Method: telnet

telnet example.com 80

If successful, you’ll see a blank screen or banner.


🛡️ Best Practices

PracticeWhy it Matters
Use mtr regularlyMonitor real-time issues across hops
Always test DNS + IPRule out resolution issues
Log outputsHelps with troubleshooting and SLA checks
Automate via cronSchedule checks + alerting
Multi-interface testingTroubleshoot VPNs, VLANs, or tunnels

🔚 Conclusion

By combining ping, nc, curl, traceroute, mtr, nmap, and ss, Linux admins gain unmatched flexibility in diagnosing networking issues. With scripting and automation, these tools become the backbone of robust infrastructure monitoring.

Last Update: July 27, 2025

Tagged in:

, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,