ubuntu, updated
Network troubleshooting
A short checklist from cable to application: link, IP, gateway, DNS, ports and firewall.
Work from the bottom up
Find the first step that fails. The problem is there.
| Step | Check | Command |
|---|---|---|
| 1. Link | Is the interface UP? | ip -br link |
| 2. IP | Do I have the right IP? | ip -br a |
| 3. Gateway | Can I reach the gateway? | ip r, then ping -c3 192.168.10.1 |
| 4. Internet | Can I reach an outside IP? | ping -c3 9.9.9.9 |
| 5. DNS | Do names resolve? | resolvectl query ubuntu.com |
| 6. Path | Where does it stop? | tracepath ubuntu.com (or mtr ubuntu.com) |
| 7. Service | Does the port answer? | nc -zv host 443 or curl -vI https://host |
If step 4 works but step 5 fails, it’s DNS: see Where are the DNS settings?.
Ports and connections
| What | Command |
|---|---|
| Which ports are listening, and which process | sudo ss -tulpn |
| Is something listening on port 80? | sudo ss -tlpn 'sport = :80' |
| Established connections | ss -tn state established |
| Test a remote TCP port | nc -zv 192.168.10.30 5432 |
| HTTP(S) request with headers | curl -vI https://example.com |
A service listening on 127.0.0.1:PORT is only reachable from the server itself. For remote access it must listen on 0.0.0.0 (all IPv4) or the server’s IP.
Firewall (ufw)
Ubuntu’s firewall front end is ufw. It is installed but disabled by default.
| What | Command |
|---|---|
| Status and rules | sudo ufw status verbose |
| Allow SSH before enabling! | sudo ufw allow OpenSSH |
| Enable | sudo ufw enable |
| Allow a port | sudo ufw allow 443/tcp |
| Allow from one network only | sudo ufw allow from 192.168.10.0/24 to any port 22 |
| Delete a rule | sudo ufw status numbered, then sudo ufw delete NUMBER |
Also check for firewalls outside the server: cloud security groups, the hypervisor, the network firewall.
Live traffic
sudo tcpdump -ni ens18 port 53 # watch DNS traffic on ens18
sudo tcpdump -ni ens18 host 192.168.10.30
Restart the network
sudo netplan apply # re-apply the config
sudo systemctl restart systemd-networkd # restart the network service