Linux network down or flaky: diagnose and fix it from the terminal

A step-by-step problem-fix guide for Linux network trouble: check interfaces and routes, hunt packet loss along the path, reconnect Wi-Fi, and verify connectivity end to end.

LinuxifconfigroutingnetworkroutetroubleshootingipLow risk
Run `ip -br a` first to confirm your interfaces are UP and have an IP address.

What this covers

When a Linux box loses connectivity or the network turns slow and unreliable, the fix is a systematic walk up the stack: interface, routing, path, then connectivity. This guide uses only verified commands to find where the failure is and confirm the repair.

Symptom

?Websites or hosts are unreachable, SSH sessions drop, pings fail or lose packets, or the connection is intermittently slow — especially on a headless server or over SSH where there is no network GUI.

Check your interfaces have an address

Start at the bottom of the stack: a network problem is often just an interface that is DOWN or missing its IP address. A compact table of every interface with its state and addresses tells you in seconds whether the link itself is the problem. If your interface shows DOWN or has no address, the fix is connectivity, not routing.

One command that prints every interface with its state and IPv4/IPv6 addresses in a short table — the modern, memorable replacement for digging through `ifconfig` or the verbose `ip addr` output.

Command
$ ip -br a

Check which route the destination actually takes

If the interface looks fine, ask the kernel directly which interface, source address and gateway it would use to reach the destination. This reveals wrong default gateways or traffic leaving on the wrong interface — a common cause when some hosts work and others do not. You succeeded when the output names a sane gateway for your destination.

See exactly which interface, source address and gateway the kernel picks for a given destination — no guessing from routing tables.

Command
$ ip route get 192.168.1.10

Watch for intermittent loss over time

A single ping tells you almost nothing about a flaky connection. Run a continuous ping with timestamps to catch packet loss and latency spikes as they happen, and to correlate them with events (a reboot, a heavy download, a time of day). If replies stop or loss appears, you have reproduced the symptom and know when it strikes.

Keep pinging a host until interrupted while printing a Unix timestamp on every reply — perfect for correlating packet loss with events.

Command
$ ping -D 8.8.8.8

Find where along the path packets die

When the destination is reachable but slow or lossy, you need to know whether the problem is in your network, your ISP, or closer to the server. mtr keeps probing every hop and shows live loss and latency per router, so you can point at the exact hop where quality collapses. Loss that appears at one hop and stays through the rest of the path locates the culprit.

When a connection is slow or flaky, traceroute only shows a snapshot. mtr keeps pinging every hop and shows live loss and latency statistics per router along the path.

Command
$ mtr -rw example.com

Reconnect the link if Wi-Fi is down

If the diagnose steps showed a DOWN interface or a missing connection — common on headless servers over SSH — rebuild the link with NetworkManager. Connecting from the terminal re-establishes the association and saves the profile, so the fix also survives reboots. Success: the interface comes up and the earlier checks now show an address.

On a server or over SSH there is no GUI — NetworkManager's nmcli can scan, connect and save Wi-Fi profiles entirely from the command line.

Command
$ nmcli device wifi connect "MySSID" password "MyPassword"
▾ Undo
Undo
$ nmcli connection delete "MySSID"

Confirm the full path is healthy again

After any fix, run a traceroute to the destination: every hop should answer within reasonable round-trip times and the final hop should be the host you care about. Comparing against the mtr output from the diagnose phase shows whether the bad hop is gone or improved. Consistent, complete replies mean the path is verified end to end.

The classic forgotten-syntax command: `traceroute` shows every router between you and a destination plus the round-trip time of probes to each hop.

Command
$ traceroute example.com

Verify outbound connectivity from the outside

Finally, confirm you can actually reach the internet, not just your gateway. Printing your outbound public IPv4 address proves DNS, routing and NAT all work end to end. If it returns an address, your connection is fully restored — and if a VPN is involved, it also tells you whether traffic is really leaving through it.

LinuxCheck Your Public IP Address with curlLow riskStep 7Optional

One-liner to print the outbound public IPv4 address of your router or VPN from the command line.

Command
$ curl -s https://api.ipify.org
!Changing network settings over SSH can lock you out of the machine — keep the existing session open until you have confirmed the new configuration works.

How to confirm it worked

A clean traceroute to your destination with consistent replies, plus a successful public IP lookup, confirms routing and outbound connectivity are restored.

Undo everything

Every command above can be reverted. Run these in order to undo all of it.

Undo everything
$ nmcli connection delete "MySSID"

Review before running — some steps may not be independent.

Sources

Last verified: 2026-09-21

Related guides