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.
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
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.
$ ip -br aCheck 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.
$ ip route get 192.168.1.10Watch 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.
$ ping -D 8.8.8.8Find 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.
$ mtr -rw example.comReconnect 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.
$ nmcli device wifi connect "MySSID" password "MyPassword"▾ 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.
$ traceroute example.comVerify 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.
One-liner to print the outbound public IPv4 address of your router or VPN from the command line.
$ curl -s https://api.ipify.orgHow 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.
$ nmcli connection delete "MySSID"Review before running — some steps may not be independent.
Sources
- ip(8) — Linux manual pageEvidence: Documents `ip -br addr` as the brief, one-line-per-interface output format of the ip command
- ip-route(8) — main IPv4/IPv6 routing table managementEvidence: Page documents the 'get' subcommand ('ip route get' — get a single route) and route attributes like via/dev/src; confirms 'ip route' and 'get' appear in the text.
- ip-route(8) — Ubuntu man pageEvidence: Man page contains the 'get' subcommand description showing it performs a route lookup and returns the resolved via/dev/src values.
- ping(8) — send ICMP ECHO_REQUEST to network hostsEvidence: Documents -D to print timestamps before each line and -i interval / -c count semantics.
- mtr(8) — combines the functionality of traceroute and pingEvidence: Documents mtr as traceroute+ping combined, and the -r report mode with -w wide format
- MTR — My TracerouteEvidence: Official mtr project page describing its real-time route/loss statistics display
- nmcli(1) — command-line tool for controlling NetworkManagerEvidence: Documents `nmcli device wifi connect <SSID> password <pass>` and `nmcli device wifi list` for scanning
- traceroute(8) — print the route packets trace to network hostEvidence: Documents traceroute's default UDP probing, TTL increments, and output format with hop latency
Last verified: 2026-09-21
Related guides
Three commands to see your Linux machine's IP: list every interface, ask the kernel which source address it really uses, and confirm it sits on the default route.
Diagnose and fix DNS resolution failures on systemd-based Linux: confirm the interface has an IP, inspect the live resolver status, query the resolver directly, flush the stub cache and set known-good DNS servers.
Find the process leaking file descriptors with ss and lsof, then raise the limit with ulimit and make it persist across logins.