Sub topic 12
Troubleshooting Common Failures
This chapter assumes that you can use a Linux shell, edit configuration files, use sudo, and read basic IPv4 addresses and subnet prefixes. It also assumes that you know whether the server uses Netplan or NetworkManager.
Troubleshoot in layers. Check the local interface first, then the route, the gateway, external addresses, and finally DNS. A later test cannot succeed when an earlier layer is broken.
Use a fixed diagnostic order
Run these commands as a starting point:
ip -br address show
ip route show
ip route get 9.9.9.9
resolvectl statusThe output answers four questions:
- Does the expected interface have the expected address?
- Does the interface have a default route?
- Which interface and gateway will the kernel use for an outside address?
- Which DNS servers and search domains does the resolver use?
Use ip link show to check whether the interface is administratively up. An interface can have an address but still be disconnected from the network.
Interpret common failures
| Symptom | Likely cause | Check |
|---|---|---|
| No address on the interface | DHCP is disabled, or static configuration did not apply | `ip -br address show` and the manager status |
| Gateway is unreachable | Wrong prefix, wrong gateway, disconnected link, or VLAN problem | `ip route`, `ip route get`, and `ping` |
| Outside IP works but names fail | Resolver address or resolver service is wrong | `resolvectl status` and `resolvectl query example.com` |
| Local hostname is wrong | Runtime hostname, `/etc/hostname`, or `/etc/hosts` is inconsistent | `hostnamectl` and `getent hosts "$(hostname)"` |
| SSH stopped after a change | Address, route, firewall, or SSH listening address changed | Use the console or out-of-band access |
A prefix length defines which addresses Linux considers local. For example, 192.168.1.50/24 treats 192.168.1.1 as local through the same interface. A mistaken /16 or /32 can make the kernel choose the wrong path to the gateway. Check the route selected for a destination:
ip route get 192.168.1.1
ip route get 9.9.9.9If the first command reports an unexpected device or gateway, correct the address, prefix, or route. If the second command reports no route, add or restore a default route through the configured gateway.
Separate routing problems from DNS problems
Test an IP address before testing a name:
ping -c 3 192.168.1.1
ping -c 3 9.9.9.9
resolvectl query example.com
getent hosts example.comA failed ping does not always prove that the network is broken. Firewalls may block ICMP. However, the comparison is useful:
- Gateway failure usually points to the local link, VLAN, prefix, gateway, or firewall.
- Gateway success but outside-address failure points to routing, upstream filtering, or the gateway.
- Outside-address success but
resolvectl queryfailure points to DNS. resolvectl querysuccess butgetent hostsfailure points to the system name-service configuration, such asnsswitch.confor a local resolver integration problem.
getent tests the name-service path used by applications. A DNS-specific command alone does not test that complete path.
Check hostname resolution
The hostname should match the intended fully qualified domain name:
hostnamectl
hostnamectl --static
getent hosts web01.example.com
getent hosts "$(hostname)"Inspect /etc/hosts when local lookups return an old address or fail. Keep one deliberate mapping for the server's own name. Remove stale entries that point the same name to an old address. The order in /etc/nsswitch.conf determines whether the system checks files, DNS, or another source first.
Recover safely
If a remote change breaks SSH, stop retrying configuration commands from the disconnected session. Use the server console, a hypervisor console, or an out-of-band management channel. Inspect the active configuration, restore the last known-good file, and reapply it with the correct manager.
For a change that affects only DNS, test an IP route first. For a change that affects the address or gateway, schedule maintenance and keep a recovery path available.
Exercise
The server can reach 9.9.9.9, but getent hosts example.com returns no result. What should you check first?
Show answer
Check resolvectl status for valid DNS servers, then run resolvectl query example.com. If that works, inspect /etc/nsswitch.conf and the resolver integration used by the distribution.