Network Troubleshooting Tools¶
Network troubleshooting is a critical skill for DevOps engineers. These tools help diagnose connectivity issues, performance problems, and service availability.
Ping - Connectivity Testing¶
tldr: ping
Send ICMP ECHO_REQUEST packets to network hosts. See also: mtr.
# Ping a host
ping <host>
# Limit to a specific number of packets
ping -c <count> <host>
# Set interval between requests (seconds; default 1)
ping -i <seconds> <host>
# Suppress DNS hostname lookups
ping -n <host>
# Also display a message if no response was received
ping -O <host>
# IPv6 — ping all local-network hosts
ping -6 ff02::1%eth0
More info: https://manned.org/ping
Ping tests basic network connectivity and measures round-trip time to a destination.
Understanding Ping¶
Comprehensive guide explaining ping functionality, parameters, and interpretation of results.
Common Ping Usage¶
# Basic connectivity test
ping google.com
# Send specific number of packets
ping -c 4 google.com
# Set packet interval (seconds)
ping -i 2 google.com
# Flood ping (requires root)
sudo ping -f target-host
# IPv6 ping
ping6 ipv6.google.com
Telnet - Port Connectivity Testing¶
tldr: telnet
Connect to a specified port of a host using the telnet protocol.
# Connect to default port of a host
telnet <host>
# Connect to a specific port (common use: test if port is open)
telnet <ip_address> <port>
# Exit an interactive session
quit
# Send the escape character to terminate the session
# Press: Ctrl+]
More info: https://manned.org/telnet
Telnet is invaluable for testing if specific ports are open and accessible on remote hosts.
Telnet Resources¶
Complete guide to telnet usage and practical examples.
Practical troubleshooting scenarios using telnet for various protocols.
Telnet Usage Examples¶
# Test HTTP port
telnet google.com 80
# Test HTTPS port
telnet google.com 443
# Test SSH port
telnet server.example.com 22
# Test SMTP port
telnet mail.example.com 25
# Test custom application port
telnet app-server.local 8080
cURL - HTTP/API Testing¶
tldr: curl
Transfer data from or to a server. Supports HTTP, HTTPS, FTP, SCP, and more.
# GET request
curl https://example.com
# Follow redirects and dump response headers
curl -L -D - https://example.com
# Download a file using the remote filename
curl -O https://example.com/filename.zip
# POST JSON data
curl -X POST -d '{"name":"bob"}' -H 'Content-Type: application/json' http://example.com/users
# Pass a bearer token header
curl -H 'Authorization: Bearer <token>' https://example.com
# Verbose output (TLS handshake, headers, timing)
curl -v https://example.com
# Test through a proxy (e.g. Burp Suite)
curl -x http://127.0.0.1:8080 https://example.com
More info: https://curl.se/docs/manpage.html
cURL is essential for testing web services, APIs, and HTTP-based applications.
cURL Resources¶
Comprehensive guide covering API testing and troubleshooting with cURL.
cURL Examples¶
# Basic GET request
curl https://api.example.com/users
# GET with headers
curl -H "Authorization: Bearer token123" https://api.example.com/data
# POST request with JSON data
curl -X POST \
-H "Content-Type: application/json" \
-d '{"username":"test","password":"secret"}' \
https://api.example.com/login
# Download file
curl -O https://example.com/file.zip
# Follow redirects
curl -L https://bit.ly/shortened-url
# Save response headers
curl -I https://example.com
# Test with different user agents
curl -A "Mozilla/5.0" https://example.com
# Upload file
curl -F "file=@document.pdf" https://upload.example.com
# Basic authentication
curl -u username:password https://protected.example.com
Additional Network Tools¶
Comprehensive Network Troubleshooting¶
Complete reference for network troubleshooting commands and utilities.
Quick Reference (tldr)¶
tldr: ip
Show and manipulate routing, devices, policy routing, and tunnels.
ip address # Show all network interfaces
ip addr show eth0 # Show info for a specific interface
ip -br address # Brief summary of all interfaces
ip route show # Show routing table
ip route add default via <gateway> # Add a default route
ip link set eth0 up # Bring an interface up
ip neighbor # Show ARP/neighbor table
tldr: ss
Utility to investigate sockets — modern replacement for netstat.
tldr: netstat
Display open connections, socket ports, and routing information.
tldr: lsof
List open files and the corresponding processes.
tldr: dig
DNS lookup utility.
dig example.com # A records (with full output)
dig +short example.com # IP addresses only
dig example.com MX # Query a specific record type
dig @8.8.8.8 example.com # Query a specific DNS server
dig -x 8.8.8.8 # Reverse lookup (PTR record)
dig +trace example.com # Full iterative trace from root servers
dig +tcp example.com # Force TCP instead of UDP
tldr: nslookup
Query name servers for various domain records.
tldr: host
Simple DNS lookup. See also: dig, nslookup.
tldr: traceroute
Print the route packets take to a network host. See also: mtr.
tldr: mtr
Matt's Traceroute: combined traceroute + continuous ping. See also: traceroute, ping.
mtr example.com # Live trace with per-hop loss/latency
mtr -n example.com # No DNS resolution
mtr -w example.com # Wide report (10 pings per hop, then exit)
mtr -z example.com # Show Autonomous System Number per hop
mtr -4 example.com # Force IPv4
mtr -i 10 example.com # 10-second interval between probes
tldr: iperf3
Traffic generator for testing network bandwidth.
iperf3 -s # Run as a server (wait for connections)
iperf3 -s -p <port> # Server on a specific port
iperf3 -c <server_ip> # Run bandwidth test to server
iperf3 -c <server_ip> -P 4 # 4 parallel streams
iperf3 -c <server_ip> -R # Reverse direction (server → client)
iperf3 -c <server_ip> -t 30 # Test for 30 seconds
tldr: tcpdump
Capture and dump network traffic.
sudo tcpdump -D # List available interfaces
sudo tcpdump -i eth0 # Capture on eth0
sudo tcpdump host example.com # Filter by host
sudo tcpdump port 443 # Filter by port
sudo tcpdump src 192.168.1.1 and dst port 80 # Source + destination filter
sudo tcpdump -w dump.pcap port not 22 # Write to file (exclude SSH)
tcpdump -r dump.pcap # Read and replay a capture file
tldr: nmap
Network exploration tool and port scanner.
tldr: nc (netcat)
Redirect I/O into a network stream.
nc -zv <host> 80-443 # Scan a port range (verbose)
nc -l -p <port> # Start a TCP listener
nc <host> <port> # Connect to a host:port
nc < file -l -p <port> # Send a file via listener
nc <host> <port> > out.file # Receive a file from a listener
nc -l -p <port> | nc <host> <remote_port> # Simple TCP proxy
Essential Network Commands¶
# Network interface information
ip addr show # Show all interfaces
ip route show # Show routing table
ifconfig # Legacy interface configuration
# DNS troubleshooting
nslookup domain.com # DNS lookup
dig domain.com # Detailed DNS information
host domain.com # Simple DNS lookup
# Network connections
netstat -tuln # Show listening ports
ss -tuln # Modern replacement for netstat
lsof -i :80 # Show processes using port 80
# Network performance
traceroute google.com # Trace packet route
mtr google.com # Continuous traceroute
iperf3 -s # Network performance testing
# Packet analysis
tcpdump -i eth0 # Capture network packets
wireshark # GUI packet analyzer
# Network scanning
nmap -sT target-host # TCP port scan
nc -zv host 80-443 # Port range scanning with netcat
Troubleshooting Methodology¶
Systematic Approach¶
- Layer 1 - Physical: Check cables, hardware status
- Layer 2 - Data Link: Verify interface status, VLAN configuration
- Layer 3 - Network: Test IP connectivity, routing
- Layer 4 - Transport: Verify port accessibility, firewall rules
- Layer 7 - Application: Test application-specific functionality
Common Network Issues¶
| Issue | Symptoms | Tools to Use | Typical Causes |
|---|---|---|---|
| No Connectivity | Cannot reach host | ping, traceroute | Network down, wrong IP, firewall |
| DNS Problems | Can ping IP but not hostname | nslookup, dig | DNS server issues, wrong configuration |
| Port Blocked | Connection refused | telnet, nmap | Firewall, service not running |
| Slow Performance | High latency, timeouts | mtr, iperf3 | Network congestion, routing issues |
| SSL/TLS Issues | Certificate errors | curl -v, openssl | Certificate problems, wrong configuration |
DevOps-Specific Scenarios¶
Container Networking¶
# Test container connectivity
docker exec container-name ping host.docker.internal
# Check container port mapping
docker port container-name
# Network troubleshooting in Kubernetes
kubectl exec -it pod-name -- ping service-name
kubectl describe service service-name
Load Balancer Testing¶
# Test load balancer endpoints
for i in {1..10}; do curl -s http://load-balancer.example.com | grep server; done
# Check SSL certificate
curl -vI https://load-balancer.example.com 2>&1 | grep -E "(Server|SSL|TLS)"
# Test with specific headers
curl -H "Host: backend.internal" http://load-balancer-ip/
Monitoring Integration¶
# Health check scripts
#!/bin/bash
if ping -c 1 target-host &> /dev/null; then
echo "Host is reachable"
exit 0
else
echo "Host is unreachable"
exit 1
fi
# Service availability check
#!/bin/bash
if curl -f -s http://service-endpoint/health; then
echo "Service is healthy"
else
echo "Service is unhealthy"
exit 1
fi
Next Steps¶
Master these troubleshooting tools, then move on to:
- Containers & Orchestration - next major section
Best Practices
- Always start with basic connectivity (ping)
- Document your troubleshooting steps
- Use verbose modes (-v) for detailed output
- Combine multiple tools for comprehensive diagnosis
- Automate repetitive troubleshooting tasks
Security Considerations
- Some tools require elevated privileges
- Be careful with network scanning in production
- Respect rate limits when testing APIs
- Follow your organization's security policies