Skip to content

23. Network Troubleshooting

When an application goes offline, blaming the network is the default response. A DevOps engineer must be able to methodically prove exactly where the failure is occurring.

23.1 The Troubleshooting Methodology (Bottom-Up)

Section titled “23.1 The Troubleshooting Methodology (Bottom-Up)”

When diagnosing a network issue, never guess. Use the OSI model to work your way from the physical hardware up to the application layer. If you skip a step, you will waste hours debugging a web server when the ethernet cable is simply unplugged.

1. Physical (Is the cable plugged in? Is the VM NIC attached?)
↓
2. Interface (Is the interface 'UP' in the OS?)
↓
3. IP (Does the interface have the correct IP address?)
↓
4. Route (Do we have a Default Gateway to reach the outside?)
↓
5. DNS (Can we resolve domain names to IPs?)
↓
6. Port (Is the firewall open? Is the service listening on the port?)
↓
7. Service (Is the background daemon actually running?)
↓
8. App (Is the application returning an HTTP 500 error?)

Check if the interface exists and if its state is UP.

Terminal window
ip link show

Verify the machine has the correct IP address.

Terminal window
ip addr show

(If you have an IP starting with 169.254.x.x, your DHCP server is unreachable/failing!).

4. Routing & Connectivity (ping, ip, traceroute)

Section titled “4. Routing & Connectivity (ping, ip, traceroute)”

First, check if you have a default gateway:

Terminal window
ip route show

Next, test if you can reach the gateway, and then test the internet:

Terminal window
# Ping the local gateway first
ping 192.168.1.1
# Ping an external IP (bypassing DNS) to prove internet connectivity
ping 8.8.8.8
# If ping fails, use traceroute to find exactly which router is dropping the packets
traceroute 8.8.8.8

If you can ping 8.8.8.8, but you cannot ping google.com, your internet is fine, but your DNS is broken.

  • nslookup: A simple tool to query a hostname.
    Terminal window
    nslookup google.com
  • dig: The advanced tool for DNS troubleshooting. It provides detailed information about MX, TXT, and A records.
    Terminal window
    # Query a specific DNS server (e.g., Cloudflare) for a domain
    dig @1.1.1.1 google.com

If DNS and routing work, the next step is checking if the port is actually open and listening.

  • ss: Check if the service is listening locally on the server.
    Terminal window
    sudo ss -tulpn | grep 443
  • nc (Netcat): The ultimate tool for testing if a port is reachable from the outside (bypassing the firewall).
    Terminal window
    # Check if port 443 is open on a remote server
    nc -zv webserver.internal.local 443
    # Output: "Connection to webserver.internal.local 443 port [tcp/https] succeeded!"

7 & 8. Services & Applications (curl, wget, tcpdump)

Section titled “7 & 8. Services & Applications (curl, wget, tcpdump)”

If the port is open, you need to check if the application is returning valid data.

  • curl: Fetches HTTP headers and bodies. Perfect for testing REST APIs.
    Terminal window
    # Fetch only the HTTP headers (-I) to check the status code (e.g., 200 OK or 502 Bad Gateway)
    curl -I https://google.com
  • wget: Designed for downloading files recursively, but useful for testing basic HTTP fetch.
  • tcpdump (The Final Boss): If everything else fails, you must inspect the raw packets on the wire. tcpdump captures network traffic so you can see exactly what is being sent and received.
    Terminal window
    # Capture all traffic on port 80 for the eth0 interface
    sudo tcpdump -i eth0 port 80