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.

StepCheckCommand
1. LinkIs the interface UP?ip -br link
2. IPDo I have the right IP?ip -br a
3. GatewayCan I reach the gateway?ip r, then ping -c3 192.168.10.1
4. InternetCan I reach an outside IP?ping -c3 9.9.9.9
5. DNSDo names resolve?resolvectl query ubuntu.com
6. PathWhere does it stop?tracepath ubuntu.com (or mtr ubuntu.com)
7. ServiceDoes 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

WhatCommand
Which ports are listening, and which processsudo ss -tulpn
Is something listening on port 80?sudo ss -tlpn 'sport = :80'
Established connectionsss -tn state established
Test a remote TCP portnc -zv 192.168.10.30 5432
HTTP(S) request with headerscurl -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.

WhatCommand
Status and rulessudo ufw status verbose
Allow SSH before enabling!sudo ufw allow OpenSSH
Enablesudo ufw enable
Allow a portsudo ufw allow 443/tcp
Allow from one network onlysudo ufw allow from 192.168.10.0/24 to any port 22
Delete a rulesudo 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
§ home
~/knubertus/home/
1,1 Top