Network troubleshooting from the terminal
Check addresses, routes, open ports, DNS and HTTP, in that order.
Work from the bottom up. Each layer must work before the next one can.
- Do I have an address and a route?
ip addrandip route. - Can I reach the gateway and the internet by IP?
ping -c 3 192.168.1.1thenping -c 3 1.1.1.1. - Does a name resolve?
dig example.comorgetent hosts example.com. - Is the port open?
nc -vz example.com 443orcurl -v https://example.com. - Is something listening locally?
ss -tlnp.
ip -br addr # short list of interfaces and addresses
ip route # default gateway
ss -tlnp # listening TCP ports and their processes
dig +short example.com # resolved addresses
curl -I https://example.com # response headers onlyReading the result
- Ping by IP works but by name fails: a DNS problem.
- Name resolves but the connection times out: a firewall or routing problem.
- Connection refused: the host answers but nothing listens on that port.
Noteping can be blocked by a firewall even when the service works. A failed ping alone does not prove the host is down.
Test yourself
Answer all the questions, then check them. Finish with every answer right to mark the lesson as done.