Network connectivity failure: how to diagnose
Topic: Servers linux
Summary
When the server cannot reach the network or others cannot reach it: check interface, IP, route, DNS, and firewall. Use ping, ip, ss, and traceroute to isolate whether the problem is local, routing, or remote.
Intent: Troubleshooting
Quick answer
- Local: ip addr (has IP?), ip link (interface up?); ping gateway; if no ping to gateway, check cable, switch, or cloud network config.
- Routing: ip route (default route?); ping 8.8.8.8; traceroute 8.8.8.8; fix gateway or route if missing or wrong.
- DNS: getent hosts example.com or dig example.com; fix /etc/resolv.conf or netplan/NetworkManager DNS; firewall: ensure outbound and required inbound ports allowed.
Prerequisites
Steps
-
Check interface and IP
ip addr show; ip link set IF up if down; ensure correct IP and no duplicate; ping the gateway from the host.
-
Check default route
ip route; default via GATEWAY; if missing add with ip route add default via GATEWAY; ping 8.8.8.8.
-
Check DNS
getent hosts google.com; cat /etc/resolv.conf; fix nameservers in netplan or NM if wrong; ping by name.
-
Check firewall and service reachability
From another host: telnet SERVER 80 or nc -zv SERVER 80; on server ufw status or nft list; allow port if blocked.
Summary
You will diagnose network failures by checking the interface, IP, default route, DNS, and firewall so you can fix local config or identify an upstream problem.
Prerequisites
- Shell access; optionally console if SSH is broken.
Steps
Step 1: Check interface and IP
ip addr show
ip link show
ping -c 2 GATEWAY_IP
Step 2: Check default route
ip route
ping -c 2 8.8.8.8
Step 3: Check DNS
getent hosts google.com
cat /etc/resolv.conf
Step 4: Check firewall and service reachability
From client: nc -zv SERVER 22. On server: allow the port in ufw/nftables.
Verification
- Ping gateway and 8.8.8.8; name resolution works; required ports reachable from outside.
Troubleshooting
No default route — Add via netplan or ip route add default via GATEWAY; make permanent in config.
DNS fails — Fix resolv.conf or netplan nameservers; ensure outbound UDP/TCP 53 allowed if using remote DNS.